<?php
//call mysql_connect() and mysql_select_db() here
//OPERATIONS:
//The Following if...elseif statements are for the Operations
if($op == "op_1")
{
$error = "";
if(!$_POST[user])
{
$error .= "<li><font color=red>Please Provide A Username To Login</font>";
}
if(!$_POST[pwd])
{
$error .= "<li><font color=red>Please Provide A Password To Login</font>";
}
$password = trim($_POST[pwd]);
$pwd_encrypt = md5($password);
$select = "select user, pwd from user_auth where user = '" . $_POST[user] . "' and pwd = '" . $pwd_encrypt . "'";
$result = mysql_query($select);
$num_rows = mysql_num_rows($result);
if($num_rows == 0)
{
$error .= "<li><font color=red>Invalid Login Username Or Password</font>";
}
if(!$error)
{
//go to next html view
$view = "view_1";
$op = "";
$user = $_POST[user];
$pwd = $pwd_encrypt;
}
else
{
$error = "<font color=red>These Errors Occured On Login:</font><br><ul>" . $error . "</ul>";
$view = "";
$op = "";
}
}
//VIEWS:
//The following if...elseif statements determine the page View
if(!$view)
{
if($error)
{
echo($error);
}
?>
<form action=index.php method=post>
<p align="center"><b>Please Login To Access:</b></p>
<table align="center" border="0">
<tr>
<th>
Username:
</th>
<th>
<input type="text" name="user">
</th>
</tr>
<tr>
<th>
Password:
</th>
<th>
<input type="password" name="pwd">
</th>
</tr>
<tr>
<th colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</th>
</tr>
</table>
<input type=hidden name=op value="op_1">
</form>
<?php
}
?>
This is how I do it.
Robogenus