i am using the following php code
<?php
if(isset($_POST["submit"])) { // If the form submitted.
$name = isset($POST["name"]) ? $POST["name"] : "";
$phone = isset($POST["phone"]) ? $POST["phone"] : "";
$country = isset($POST["country"]) ? $POST["country"] : "";
if(trim($phone) != "" && trim($name) != "" && trim($country) != "") {
$link = mysql_connect('your_host', 'username', 'password') or die("DB Connection error : " . mysql_error());
mysql_select_db('db_name', $link) or die("DB Selection error : " . mysql_error());
$query = "INSERT INTO your_table(name, phone) VALUES('".mysql_real_escape_string($name)."','".mysql_real_escape_string($phone)."')";
$mysql_query($query) or die("Insert query error : " . mysql_error());
header("Location : redirect_page.php");
exit();
}
if(trim($name) == "" ) {
$nameError = true;
echo "<b> Please fill out the name field. </b> <br>";
}
if(trim($phone) == "" ) {
$phoneError = true;
echo "<b> Please fill out the phone field. </b> <br>";
}
if(trim($countryError) == "" ) {
$countryError = true;
echo "<b> Please fill out the country field. </b> <br>";
}
// similarly other fields
}
?>
<html>
<body>
<form name="myform" action="<?=$PHP_SELF?>" method="POST">
<table border='1' width='50%'>
<tr bgcolor='<?=($nameError) ? "GREY" :""?>'>
<td>Enter your name :</td>
<td><input type="text" name="name" /></td>
</tr>
<tr bgcolor='<?=($phoneError) ? "GREY" :""?>'>
<td>Enter your phone :</td>
<td><input type="text" name="phone" /></td>
</tr>
<tr bgcolor='<?=($countryError) ? "GREY" :""?>'>
<td>Enter your Country :</td>
<td><input type="text" name="country" /></td>
</tr>
<!-- other fields -->
<tr>
<td colspan='2'><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
so, is there a way to get this to go to another page when all the input is correct?
many thanks