Jump to content

PHP help with signing in


Vigilant Psyche

Recommended Posts

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

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.