Vigilant Psyche Posted March 22, 2008 Share Posted March 22, 2008 I'll try to be clear, just ask if necessary though: The problem is that the bit that actually changes the variable $_SESSION["CURRENT_USER"] (ie signing in) is below the place where I check that variable, meaning that this check wont be performed with the new variable till next time you refresh the page... Any ideas how to solve this? The source has been is below... any ideas on how to right this? Thanks for any help, guys. <?php if ($_SESSION["CURRENT_USER"]=='') //IF NOT LOOGED IN (OPTIONS) { echo(" <form action='index.php' method='post' class='back_black color_white'> Username: <br><input type='text' name='username' class='border_gray back_black color_white'/><br> Password: <br><input type='password' name='password' class='border_gray back_black color_white'/><br><br> <input type='submit' value='Sign in' class='border_gray'/> <a href='index.php?body=register'>Register</a> </form> "); } ?> <?php if($_POST['username'] != "" && $_POST['password'] != "") { $username=$_POST['username']; $password=$_POST['password']; $result=mysql_query("SELECT name FROM user WHERE pass='$password' AND name='$username'"); while($r=mysql_fetch_array($result)) $_SESSION["CURRENT_USER"]=$r[name]; } ?> Link to comment https://forums.phpfreaks.com/topic/97408-php-help-with-signing-in/ Share on other sites More sharing options...
BlueSkyIS Posted March 22, 2008 Share Posted March 22, 2008 move your code to the top of the page instead of the bottom? Link to comment https://forums.phpfreaks.com/topic/97408-php-help-with-signing-in/#findComment-498434 Share on other sites More sharing options...
Vigilant Psyche Posted March 22, 2008 Author Share Posted March 22, 2008 But i need the button (and hence the bit which catches the variable) to be lower than the options. Is there a way to make my button refresh the page after changing the variable? Link to comment https://forums.phpfreaks.com/topic/97408-php-help-with-signing-in/#findComment-498436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.