Jump to content

IF statement not working


markt97

Recommended Posts

Hi,

My if statement is not working for session variables, please help!

 

Login page (Sets session):

 $email = mysqli_real_escape_string($con,$_POST['username']); 
   $pass = mysqli_real_escape_string($con,$_POST['password']); 
   $mysql = mysqli_query($con,"SELECT * FROM users WHERE email_address = '{$email}' AND password = '{$pass}'"); 
   $mysql2 = mysqli_fetch_array($mysql);
   if (!$mysql ||mysqli_num_rows($mysql) < 1)
   {
     die("Incorrect password!");
   } 
   $_SESSION['loggedin'] = "YES"; 
   $_SESSION['email'] = $email; 
   $_SESSION['fname'] = $mysql2['first_name'];
   $_SESSION['lname'] = $mysql2['last_name'];
   $_SESSION['add1'] = $mysql2['address_1'];
   $_SESSION['add2'] = $mysql2['address_2'];
   $_SESSION['county'] = $mysql2['county'];
   $_SESSION['postcode'] = $mysql2['postcode'];
   $_SESSION['tel'] = $mysql2['tel_no'];
   $_SESSION['mobile'] = $mysql2['mobile_no'];
   $_SESSION['team'] = $mysql2['team'];
   $_SESSION['ismanager'] = $mysql2['is_manager'];
   $_SESSION['isadmin'] = $mysql2['is_admin'];
   $_SESSION['sysadmin'] = $mysql2['is_sysadmin'];

Then on the profile page: 

 
<tr>
<td class="profile_tab">
    Is Team Manager?</td>
    <td class="profile_tab"><input style="text-align: center; font-size: 14pt;" type="text" value="<?PHP if($_SESSION['ismanager'] = "1") {echo "YES";} else {echo "NO";};?>" disabled size="50"></td>
</tr>
<tr>
<td class="profile_tab">
    Is Administrator?</td>
    <td class="profile_tab"><input style="text-align: center; font-size: 14pt;" type="text" value="<?PHP if($_SESSION['isadmin'] = "1") {echo "YES";} else {echo "NO";};?>" disabled size="50"></td>
</tr>
<tr>
<td class="profile_tab">
    Is System Administrator?</td>
    <td class="profile_tab"><input style="text-align: center; font-size: 14pt;" type="text" value="<?PHP if($_SESSION['sysadmin'] = "1") {echo "YES";} else {echo "NO";};?>" disabled size="50"></td>
</tr>

However the echo on the if statement doesn't work and just shows yes.....

 

I have changed in DB my value of is admin to 0 and it still says yes on my profile page,

 

Any help appreciated!

 
Link to comment
https://forums.phpfreaks.com/topic/284560-if-statement-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.