I need to write a small php script that would do the following:
Connect to a MySQL database, and check the user_id table for a user number that is entered through an HTML form. If the user number is found, then direct the user to aaa.html page, if not found, direct him to bbb.html page.
Here is what I've come up with:
<?
$host = "localhost";
$user = "username";
$pass = "password";
$dbname = "database";
$table = "user_id";
$connection = @mysql_connect("$host","$user","$pass") or
die ("Could not connect to database");
// THIS IS THE PART I HAVE NO IDEA HOW TO DO
$query = "SELECT*from $table";
$result = mysql_db_query ($dbname, $query, $connection);
// END
if ($result == $user_id) {
header ("Location: aaa.html");
} else if ($result) {
header ("Location: bbb.html");
}
?>
$user_id is the variable passed from the HTML form.
The part that I've marked is probably absolutely useless, since I have no idea what it does. The rest of the code I wrote myself but it probably also has mistakes.
Can anyone give me a hint how to do this. Thanks in advance!!!