Forum Moderators: coopster
Have you had a look at the PHP header [php.net] function?
if (text field = database value) {
header("Location: [example.com...] /* Redirect browser */
exit;
}
// otherwise, format your error message and display the form again.
Something like the following is the complete version of what you want:
<?php//setup a connection to the database
$db = mysql_connect("server", "user", "pass");
mysql_select_db("database", $db);
//Assuming the information is brought from a <form> and
//that you use the POST method, we can do the following
//This sets the information from the form into an easy
//to use variable
$input_data = $_POST['data_from_form'];
//now we need to create a MySQL query to test if the
//data in $input_data matches what we have in our db
$sql = "SELECT * FROM table_name WHERE some_variable = '".$input_data."'";
//What we have done here is say that we want to select
//all (*) the records from our database table that
//match our input data
//Now we have to format the output from MySQL so that
//we can use it. If this response is '0' then we know
//that this item is not in the database. If it is
//Greater than or equal to 1, then it is in the db
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$some_variable= $row["some_variable"];
}
//now we need to do an if() function to find out if
//this value is 0 or >0
if($some_variable = '0'){
header("Location: http://www.example.com/error.php"); /* Redirect browser to your error page */
exit;
}else{
header("Location: http://www.example.com/success_page.php"); /* Redirect browser somewhere good! */
}
mbcx9rvt
exit;