salukigirl
New Member
- Messages
- 78
- Reaction score
- 0
- Points
- 0
How do I keep my verify script from letting users get to the registration page? It won't let them to it because they are not logged in. But they can't log in if they cannot create an account...
PHP:
<?php
session_start();
include("sql_connect.php");
$username = $_POST['username'];
$password = $_POST['password'];
if ( ! isset( $username ) )
{
die('You must enter in a username.');
}
if ( ! isset( $password ) )
{
die('You must enter in a password.');
}
$user_query = mysql_query("SELECT * FROM user WHERE username='".$username."'");
$num_users = mysql_num_rows( $user_query );
if ( $num_users == 0 )
{
die('User does not exist.');
}
else
{
while ( $user = mysql_fetch_array( $user_query ) )
{
if ( $password == $user["password"] )
{
session_register("loggedIn");
session_register("username");
$_SESSION['loggedIn'] = true;
$_SESSION['username'] = $username;
echo '<meta http-equiv="refresh" content="3; URL=user.php" />';
echo 'You have successfully logged in as '.$username.'<br />';
echo 'Redirecting to the user page';
}
else
{
echo 'Password does not match.';
}
}
}
?>