PDA

View Full Version : Redirecting Problem Upon Form Submission...



Smitty
09-29-2008, 05:08 PM
Can anyone look at the code below and tell me why the Redirect to: '.../thank_you_for_your_submission.htm' doesn't launch upon submission. The data DOES get properly dispatched to the email address, yet I've failed time and time again to get the 'submission,htm' page to open. Do I need to have PHP-related code in place to tie in with my host's PHP service to make this work? Thank You in advance for any assistance you can give me.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Mail</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<FORM action="mailto:smitty@work.com?subject=EVENT FORM"
method=POST encType=text/plain>
<input type=hidden name="subject" value="Form Mail Results">
<input type=hidden name="required" value="fullname,email">
<input type=hidden name="redirect"
value="http://www.companywebsite.com/submission_received.htm">
Name<br><input type=text name="fullname"><br>
Email<br> <input type=text name="email"><br>
<br> Comments<br> <textarea name="comments"></textarea> <br>
<br> <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

gpigate
09-29-2008, 09:44 PM
I would create a PHP page to handle the email and redirect.


if ($_POST["send"]=='Y') {
...... build email based on text fields from POST VARS
..... use php mail function to send email
header("Location: http://www.companywebsite.com/submission_received.htm");
}else {

?>

display html form

<? php } ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Mail</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<FORM action="mailto:smitty@work.com?subject=EVENT FORM"
method=POST encType=text/plain>
<input type=hidden name="subject" value="Form Mail Results">
<input type=hidden name="required" value="fullname,email">
<input type=hidden name="redirect"
value="http://www.companywebsite.com/submission_received.htm">
Name<br><input type=text name="fullname"><br>
Email<br> <input type=text name="email"><br>
<br> Comments<br> <textarea name="comments"></textarea> <br>
<br> <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

Smitty
09-29-2008, 10:07 PM
While I've been doing sites for a while, this is my first time venturing into forms. Given the code that you supplied above, I'm at a loss to determine how/where that would fit into my existing code.

gpigate
09-29-2008, 10:27 PM
are you familiar with PHP?

try this... of course you may want to change around your post vars, add your validation etc.


<?php
if ($_POST['send']=='Y'){
$subject = $_POST['subject'];
$name = $_POST['fullname'];
$from = $_POST['email'];
$comments = $_POST['comments'];

$to = 'destination email address here ';

$message = "Name of Sender: ".$name."\n\n";
$message .= "Address of Sender: ".$from."\n\n";
$message .= "Message: " . $_POST["comments"] . "\n\n";

$headers = "From: ".$from."\n";

mail($to, $subject, $message, $headers);

header("Location: http://www.companywebsite.com/submission_received.htm");


} else {

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Mail</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<FORM action="testform.php" method="post" name="contactus" enctype="multipart/form-data">
<input type=hidden name="subject" value="Form Mail Results">
<input type=hidden name="required" value="fullname,email">
<input type=hidden name="send" value="Y">
<input type=hidden name="redirect" value="http://www.companywebsite.com/submission_received.htm">
Name<br><input type=text name="fullname"><br>
Email<br> <input type=text name="email"><br>
<br> Comments<br> <textarea name="comments"></textarea> <br>
<br> <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<?php } ?>

Smitty
09-30-2008, 04:18 PM
gpigate--

THANK YOU for the assistance!

gpigate
09-30-2008, 04:20 PM
not a problem. did that work for you?