I have successfully made my login page however after hours of trying to get the correct script i have amended a friends existing one. At the moment the script works fine, as far as authenticating users. However My friend had usertypes and I do not. What part of the code do I need to delete for the code to continue working without including the usertype value??
{
$query = "SELECT * FROM user WHERE accountref = '$accountref' AND pin = '$pin'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0)
{
//If user type is staff then direct to stock menu
//otherwise direct to store
if ( $row[usertype] = 1 )
{
$redirect = 1;
}
else
{
$redirect = 2;
}
}
else
{
$redirect = 3;
}
}
else
{
$redirect = 3;
}
//Close connection to server
@$disconn=mysql_close($conn);
if (!$disconn) die ("Error: Unable to disconnect from database server.");
//If not sucessful redirect back to login screen
if ($redirect == 3)
{?>
<h1>Incorrect Login Details</h1>
<form method="post" action="login.php" target="_self">
<p>
<input type="submit" value="Re-try?"/>
</p>
</form><?
}
//If sucessful direct to store
else if ($redirect == 2)
{?>
<h1>Welcome you are logged in as <?print($accountref)?><br>Proceed to the Personal Details Page</h1>
<a href="testing.php"><img src ="deitel.jpg"></a>
<form method="post" action="testing.php" target="_self">
<p>
<input type="submit" value="Continue"/>
</p>
</form><?
}
//If sucessful direct to stock menu
else if ($redirect == 1)
{?>
<h1>You are logged in as <?print($accountref)?><br>Please make your selection</h1>
<form method="post" action="testing.php" target="_self">
<p>
<input type="submit" value="Manage Stock"/>
</p>
</form>
<form method="post" action="test.php" target="_self">
<p>
<input type="submit" value="Process Orders"/>
</p>
</form>
<form method="post" action="mysqltest.php" target="_self">
<p>
<input type="submit" value="Manage Users"/>
</p>
</form>
<img src ="deitel.jpg"><?
}
?>
</body>
</html>
Many thanks!!😃