Jump to content

markt97

New Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About markt97

  • Rank
    Newbie
  1. Thanks, sorry it did work, forgot to log out and then in again!
  2. 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!
  3. Thanks so much, I added it a second ago to try it, and forgot to change the variables! Solved!
  4. Hello, I'm coding a log in page and I keep getting this problem with mysqli_result. It's a mysqli server. My error is: Fatal error: Cannot use object of type mysqli_result as array in /home/a7017672/public_html/login.html on line 34 My code is: <?PHP if(isset($_SESSION['loggedin'])) { die("You are already logged in!"); } if(isset($_POST['submit'])) { $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'] = $mysql['first_name']; $_SESSION['lname'] = $mysql['last_name']; $_SESSION['add1'] = $mysql['address_1']; $_SESSION['add2'] = $mysql['address_2']; $_SESSION['county'] = $mysql['county']; $_SESSION['postcode'] = $mysql['postcode']; $_SESSION['tel'] = $mysql['tel_no']; $_SESSION['mobile'] = $mysql['mobile_no']; $_SESSION['team'] = $mysql['team']; $_SESSION['ismanager'] = $mysql['is_manager']; $_SESSION['isadmin'] = $mysql['is_admin']; $_SESSION['sysadmin'] = $mysql['is_sysadmin']; die("You are now logged in!"); } echo "<form method='POST'> <p style='font-size: 14pt;'>Username (Email): <br><input type='text' name='username' maxlength='50' size='30'> <br /> <p style='font-size: 14pt;'>Password:<br><input type='text' name='password' maxlength='50' size='30'><br /> <input type='submit' name='submit' value='Login'> </form>"; ?> Any help is greatly appreciated!
×
×
  • 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.