<?php
if ($direct) {
header("Location: http://myfile.html"); / Redirect browser /
}
session_start();
session_register("client_id");
?>
<html>
<head>
<title>TEST</title>
</head>
<body>
<?php
// Valid form
$username = $REQUEST['login'];
$password = $REQUEST['password'];
if (empty($username) || empty($password)) {
$direct;
}
else {
include("connect.php");
// Validate login from database (form variables "login" and "password")
$sql_validate = mysql_query("SELECT username, password FROM account_details WHERE username = '$login' AND password = '$password'", $dbconnect);
// Identify client_id from database
$sql_client = mysql_query("SELECT client_id FROM account_details WHERE username = '$login' AND password = '$password'", $dbconnect);
while ($show = mysql_fetch_array ($sql_validate)) {
$showname = $show[username];
$showpassword = $show[password];
}
while ($client = mysql_fetch_array ($sql_client)) {
$client_id = $client[client_id];
}
// Get number of rows in $sql_validate. 0 if invalid, 1 if valid.
$num = mysql_numrows($sql_validate);
if ($num) {
echo "You're authorized!";
echo "Welcome" . " $showname";
echo "client id:" . " $client_id";
exit;
} else {
echo "Not authorized!";
exit;
}
}
?>
</body>
</html>