php form submit redirection
Posted: Sat Sep 09, 2006 12:49 pm
Hello,
I have this php form in the works and I want it to redirect to another page on submission
this is what I have
as you can see its simple but \
header("Location:http://www.domain.com/thanks.php?name=$_POST[name]");
exit;
is giving me an error so I cant use that any other way to have it redirect to another page on submission.... please give code examples to help me understand
I have this php form in the works and I want it to redirect to another page on submission
this is what I have
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><?php
if ($_POST['submit']) {
$required_fields = explode(",", $_POST['required']);
$error = 0;
foreach($required_fields as $fieldname) {
if ($_POST[$fieldname] == "") {
$error++;
}
}
if ($error == 0) {
if (strstr($_POST['email'], "@") and strstr($_POST['email'], ".")) {
mail("art@mellontech.com" , "Message from Web Form", $_POST['message'], "From: $_POST[name] <$_POST[email]>");
header("Location:http://www.mellonhosting.com/art/thanks.php?name=$_POST[name]");
exit;
} else {
$errormessage = "<b>The email address you entered does not appear to be valid<br></b>";
}
} else {
$errormessage = "<b>You have left some required fields in the form blank! Please fill in the form completely.";
}
}
?>
<head>
<?php
if ($_POST['submit']) {
$required_fields = explode(",", $_POST['required']);
$error = 0;
foreach($required_fields as $fieldname) {
if ($_POST[$fieldname] == "") {
$error++;
}
}
if ($error == 0) {
if (strstr($_POST['email'], "@") and strstr($_POST['email'], ".")) {
mail("art@mellontech.com" , "Message from Web Form", $_POST['message'], "From: $_POST[name] <$_POST[email]>");
header("Location:http://www.domain.com/thanks.php?name=$_POST[name]");
exit;
} else {
$errormessage = "<b>The email address you entered does not appear to be valid<br></b>";
}
} else {
$errormessage = "<b>You have left some required fields in the form blank! Please fill in the form completely.";
}
}
?>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<br><br>
<?=$errormessage?>
<br>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table width="500" border="0" cellpadding="5" cellspacing="0">
<tr><td>Your name:</td><td><input type="text" name="name" value="<?=$_POST['name']?>"></td></tr>
<tr><td>Your email:</td><td><input type="text" name="email" value="<?=$_POST['email']?>"><td><tr>
<tr><td>Your message:</td><td><textarea name="message"><?=$_POST['message']?></textarea></td></tr></table>
<input type="hidden" name="required" value="name,email,message">
<input type="submit" name="submit" value="submit">
</body>
</html>header("Location:http://www.domain.com/thanks.php?name=$_POST[name]");
exit;
is giving me an error so I cant use that any other way to have it redirect to another page on submission.... please give code examples to help me understand