<?PHP
function printHeader() {
echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Login Screen</title>
</head>
<body>
';
}
function printform() {
printHeader();
echo '
<form action="signup-1_test.php?op=login" method="post" enctype="mimetype" target="" title="">
<div align="center"><p>
<p> </p>
<h4><font face="Courier New"> </font></h4>
<table width="30%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" height="51">
<div align="center"><b>
New User ? <a href="MJscript.htm" target="_parent" name="Signup">Sign
up now!</b></a><br>
</div>
</td>
</tr>
<tr>
<td width="47%">
<div align="right"><b>Username : </b></div>
</td>
<td width="53%">
<input type="text" name="user">
</td>
</tr>
<tr>
<td>
<div align="right"><b>Password :</b> </div>
<div align="center"> </div>
</td>
<td>
<input name="pass" type="password" >
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input align="center" checked maxlength="15" name="SignUP" size="15" type="submit" value="Sign In">
</div>
</td>
</tr>
</table>
<p></p>
<p>
<p> <b> </b>
</div>
</form>
';
}
/function for varifying the user id and password is correct to database based on the values
which we got from the html form"/
function checkUser() {
global $user,$pass;
include('adodb.inc.php');
ADOLoadCode("mysql");
$connection = NewADOConnection();
$connection->Connect("localhost","","","testdatabase");
$sql_result = $connection->Execute("SELECT * FROM employee WHERE id='$user' AND password='$pass'" ) or die("could not connect the database");
$temp_count=$sql_result->RecordCount();
if ($temp_count>0)
{
/if the user id and password is correct it should redirect to this form"/
// Header("Location: http://php.net/");
Header("Location: http://localhost:/usr_option.php");
}
else
{
/if it is not exixting just send and invalid user message and stay in the same form/
Header("Location: http://localhost:/signup-1_test.php/");
}
}
if(isset($op)) {
switch ($op) {
case 'login':
checkUser();
break;
default:
printform();
break;
}
}
else {
printform();
}
echo '
</body>
';
?>
Steve Yelvington wrote:
Post an example of your code.