Login:
- Code: Select all
<form action="login_action.php" method="post">
<table border="0">
<tr><td>Username:</td><td><input type="text" name="Username"></td></tr>
<tr><td>Password:</td><td><input type="Password" name="Password"></td></tr>
</table>
<p>
<input type="submit" value="Login">
</form>
login_action:
- Code: Select all
function Database_Entries($msg) {
echo $msg;
}
function Output_Entries() {
/*
Make the connection to the database. The syntax is
odbc_connect( 'SYSTEM_DSN' , 'USER', 'PASSWORD' );
$cnx will hold the
pconnect is used to establish a persistent database
connection to the Database until the procedure is completed.
*/
$cnx = odbc_connect( 'gclntn' , '', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
// send a simple odbc query . returns an odbc cursor
// $cur= odbc_exec( $cnx, "SELECT Username,Password from tbl_admin WHERE Username='".$_POST["Username"]."' AND Password='".$_POST["Password"]."'");
$cur= odbc_exec( $cnx, "SELECT Username,Password from tbl_admin WHERE Username='".$HTTP_POST_VARS['Username']."' AND Password='".$HTTP_POST_VARS['Password']."'");
//$HTTP_POST_VARS['Username'] $HTTP_POST_VARS['Password']
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
$nbrow=0; //Local variable to count number of rows
// fetch the succesive result rows
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$UsernameSQL= odbc_result( $cur, 1 ); // get the field "Username"
$PasswordSQL= odbc_result( $cur, 2 ); // get the field "Password"
}
// close the connection. important if persistent connection are "On"
odbc_close( $cnx);
//echo $HTTP_POST_VARS["Username"];
echo $Username;
phpinfo();
if($nbrow>=1)
{
//Header ("Location: index.php");
}
else
{
//Header ("Location: login.php");
}
}
function Error_Handler( $msg, $cnx ) {
echo "$msg \n";
odbc_close( $cnx);
exit();
}
Output_Entries();

