I have a strange problem I have code that the php engine skips over as if it isn't there. The code its skips is "elseif ($var=='yes')" and since $var is declared within the function, the php engine should be able to read it. I don't see anything wrong with the code and am hoping someone will spot what I'm not seeing. Thanks in advance for you help!
Code: Select all
1 <?php
2
3 function fix_login($username, $passwd) {
4 // check username and password with db
5 // if yes, return true
6 // else throw error
7
8
9 // connect to db
10 $conn = db_connect();
11
12 // check if username is unique
13 $result = mysqli_query($conn, "select reg_var from clients where
14 user_name='".$username."' and password = sha1('".$passwd."')");
15
16 $row = mysqli_fetch_row($result);
17 $var = $row[0];// Declared within a function, can be seen in the else if loops
18
19 if (!$result) {
20 echo "There's a problem with the user name or password, try again <br />";
21
22 exit;
23
24 [color=#FF0000]} elseif ($var=='yes') { //WHAT IS WRONG WITH THIS?[/color]
25
26 echo "from the var equals yes loop, got the result I wanted.";
27 return true;
28
29 exit;
30
31 } elseif (mysqli_num_rows($result)>0) {
32
33 echo "from the num_rows loop ".$var .".";
34 return true;
35
36 exit;
37
38 } else {
39
40 echo "from the failure loop ".$var;
41 echo " You must first complete the registration process, please
42 check your email for a confirmation email<br />";
43
44 display_login_form();
45 exit;
46 }
47
48 mysqli_free_result($result);
49 mysqli_close($conn);
50
51 }
52
53 ?>Rick