jamesxg1 Posted April 7, 2009 Share Posted April 7, 2009 <?php session_start(); error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL ^ E_NOTICE); include 'Database/Connection.php'; $userid = mysql_real_escape_string(intval($_POST['userid'])); $username = mysql_real_escape_string($_POST['username']); $pass_word = mysql_real_escape_string($_POST['password']); $password = md5($pass_word); if (isset( $_SESSION['loggedin'] )) { header('Location: Main.php'); }else{ if (isset($_POST['submit'])) { if($username && $password && $userid) { $result = mysql_query($sql); $sql = sprintf("SELECT * FROM `members` WHERE username = '$username' AND password = '$password' AND userid = '$userid'"); $result = mysql_query($sql); $morerow = mysql_fetch_array($result); if (mysql_num_rows($result) > 0) { if ($morerow['level'] != "S") { $_SESSION['loggedin']="TRUE"; $_SESSION['username'] = $username; $_SESSION['level'] = $morerow['level']; $_SESSION['id'] = $morerow['id']; $_SESSION['lastname'] = $morerow['lastname']; $_SESSION['firstname'] = $morerow['firstname']; $_SESSION['email'] = $morerow['email']; header('Location: Main.php'); } else echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i>Your account has been suspended or banned by admin.</i></font></div>"; }else{ echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i>Invalid login<br>If you are a new user please register</i></font></div>"; } }else{ echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i> You must enter a username and password!</i></font></div>"; } } } ?> <form method="POST" action="<?php echo "$PHP_SELF"; ?>"> <p align="center"> <b>User ID:</b> <input type="text" name="userid" size="20" maxlength="255" /> </p> <p align="center"> <b>Username</b> <input type="text" name="username" size="20" maxlength="255" /> </p> <p align="center"> <b>Password</b> <input type="password" name="password" size="20" maxlength="255" /> </p> <p align="center"> <input type="submit" name="submit" value="Submit"> </p> <br /> </form> i atleast need the $_SESSION['level'] to be set but nothing is setting :S any help here guys ? Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 7, 2009 Share Posted April 7, 2009 trie this. <?php session_start(); error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL ^ E_NOTICE); include 'Database/Connection.php'; $userid = mysql_real_escape_string(intval($_POST['userid'])); $username = mysql_real_escape_string($_POST['username']); $pass_word = mysql_real_escape_string($_POST['password']); $password = md5($pass_word); if (isset( $_SESSION['loggedin'] )) { header('Location: Main.php'); }else{ if (isset($_POST['submit'])) { if($username && $password && $userid) { $result = mysql_query($sql); $sql = sprintf("SELECT * FROM `members` WHERE username = '$username' AND password = '$password' AND userid = '$userid'"); $result = mysql_query($sql); while($morerow = mysql_fetch_assoc($result){ if (mysql_num_rows($result) > 0) { if ($morerow['level'] != "S") { $_SESSION['loggedin']="TRUE"; $_SESSION['username'] = $username; $_SESSION['level'] = $morerow['level']; $_SESSION['id'] = $morerow['id']; $_SESSION['lastname'] = $morerow['lastname']; $_SESSION['firstname'] = $morerow['firstname']; $_SESSION['email'] = $morerow['email']; header('Location: Main.php'); } else echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i>Your account has been suspended or banned by admin.</i></font></div>"; }else{ echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i>Invalid login<br>If you are a new user please register</i></font></div>"; } }else{ echo "<div align=\"center\"><font color=red> <img src=\"images/exclam.PNG\"/><i> You must enter a username and password!</i></font></div>"; } } } } ?> Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 7, 2009 Share Posted April 7, 2009 $_SESSION['loggedin']="TRUE"; should be... $_SESSION['loggedin'] = true; Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 ok i changed it to lowercase and the other script that was supplyed didnt work :S Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 can anyone here help me please ? really need this. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 7, 2009 Share Posted April 7, 2009 ok i changed it to lowercase and the other script that was supplyed didnt work :S it wasn't the lowercase i was referring to .. lose the quotations to set a true/false var. have you echo'd anything out to see if the proper variables are being passed .. is $_POST['submit'] working as planned? 'cause your sessions var's are only being set if you make it to them .. if the form is failing before they are set, they will not be set :S add error_reporting(E_ALL); to the top of your script(s) so you can see what's going on (assuming you don't already have error_reporting on). and test to make sure you are reaching your sql statement. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 ok i changed it to lowercase and the other script that was supplyed didnt work :S it wasn't the lowercase i was referring to .. lose the quotations to set a true/false var. have you echo'd anything out to see if the proper variables are being passed .. is $_POST['submit'] working as planned? 'cause your sessions var's are only being set if you make it to them .. if the form is failing before they are set, they will not be set :S add error_reporting(E_ALL); to the top of your script(s) so you can see what's going on (assuming you don't already have error_reporting on). and test to make sure you are reaching your sql statement. lol ok thanks , and i havent no but i am assuming its working seeings as i get the correct errors if i enter the details wrong and it reffers me to the page that is set for if the login returns successfull i just dont understand why the sessions arent being set :S Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 does anyone know how to fix this ? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 7, 2009 Share Posted April 7, 2009 do you have session_start(); at the top of all the pages using sessions? any page that uses sessions needs to have it at the top. have you used sessions on that same server before? Quote Link to comment Share on other sites More sharing options...
schilly Posted April 7, 2009 Share Posted April 7, 2009 add echos at all of those if statements and see where it breaks. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 do you have session_start(); at the top of all the pages using sessions? any page that uses sessions needs to have it at the top. have you used sessions on that same server before? yes every page has session_start(); and yes many times Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 add echos at all of those if statements and see where it breaks. ok iv got most of it working 2 mins guys ill see if i can get the rest to . Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 7, 2009 Share Posted April 7, 2009 add echos at all of those if statements and see where it breaks. ok iv got most of it working 2 mins guys ill see if i can get the rest to . post back what you did .. curious. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.