daneth1712 Posted August 6, 2009 Share Posted August 6, 2009 Hi guys, I have another problem.... these scripts were working fine, and I dont know what has changed to make them stop working... I have a login page, with username and password fields. these then get sent to the page below; <?php $username=($_POST['username']); $password=($_POST['password']); //send back to the login form if page is called from other location if (!isset($username) || !isset($password)) { header( "Location: admin_login.html" ); } elseif (empty($username) || empty($password)) { header( "Location: admin_login.html" ); } else{ //set the database connection variables include('includes/config.php'); //connect to the database $db = mysql_connect("$hostname", "$adminuser", "$adminpass") or die ("Error connecting to database."); mysql_select_db("$database", $db) or die ("Couldn't select the database."); $result=mysql_query("SELECT * FROM $dbaccounts WHERE username='$username' AND password='$password'", $db); //check that at least one row was returned $row = mysql_num_rows($result); if($row == 1){ while($row = mysql_fetch_array($result)){ //start the session and register variable to password session_start(); $_SESSION['password']= $array['password']; header( "Location: adminlogin_successful.php" ); } } else { //if nothing is returned header( "Location: adminlogin_error.html" ); } } ?> If correct, it should go to another page which calls for <?php include('includes/sess_password.php'); ?> the sess_password.php page is below; <?php //start the session session_start(); //check to make sure the session username variable is registered if(isset($_SESSION['password'])){ $passw_id=$_SESSION['password']; } else{ //the session variable isn't registered, send them back to the login page header( "Location: admin_login.html" ); } ?> Where am I going wrong... I would have a guess at the sess_password.php page that calls for the session... Any help is really appreciated! Link to comment https://forums.phpfreaks.com/topic/169067-solved-login-and-session-problem/ Share on other sites More sharing options...
avvllvva Posted August 6, 2009 Share Posted August 6, 2009 $_SESSION['password']= $array['password']; this is supposed to be $_SESSION['password']= $row['password']; Link to comment https://forums.phpfreaks.com/topic/169067-solved-login-and-session-problem/#findComment-892011 Share on other sites More sharing options...
daneth1712 Posted August 6, 2009 Author Share Posted August 6, 2009 thanks avvllvva! I would have probably been all day to notice that.... Thanks again! Link to comment https://forums.phpfreaks.com/topic/169067-solved-login-and-session-problem/#findComment-892043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.