Can anyone help me ?
What I am trying to achieve is depending on what url and password a user puts in, they get redirected to a
certain page.
I have a database which is setup with the following fields:
username (holds username)
password (holds password)
redirector (holds the URL to redirect to)
I have a HTML page for the login area as detailed below:
<html><head><title>Log-In Page</title>
</head>
<body>
Please enter your user details to log-in here...
<form name = "form1" method="post" action="authenticate.php">
Username:<input name = "username" type="text" id="username">
<br><br>
Password:<input name = "password" type="password" id="password">
<br><br>
<input type="submit" name="Submit" value="Login">
</form>
</body></html>
The PHP code I have written by using snippets from forums is detailed below:
<?php
$Host = "localhost";
$db_user = "sdm";
$db_password = "gremlin";
$db_name = "authsystem";
#connect to MySQL
$svrConn = mysql_connect($Host, $db_user, $db_password);
if($svrConn){
#select the specified database
$db_Conn = mysql_select_db($db_name, $svrConn);
} else {
echo "Could not select database";
}
$POST['username'] = "$username";
$POST['password'] = "$password";
echo "username value: $username\n<br>";
echo "password value: $password\n<br>";
echo "<p>";
#create the query
if ($dbConn){
$strQuery = "SELECT username, password, redirector FROM users";
$strQuery .= "WHERE username = '$username'";
$strQuery .= "AND password = '$password'";
$results = mysql_query($strQuery);
$result = mysql_fetch_row($results);
if ($result) {
$custurl = $result[2];
header("Location: $custurl");
} else {
echo "No Results Returned.";
}
}
echo "<p>";
echo "$strQuery";
?>
If anyone can see why this is not working, I would be really grateful as I need to get this script
working for tomorrow if possible.
Thanks,
SDM