Jump to content

[SOLVED] email form-redirect


badproduce

Recommended Posts

I am working on a basic e-mail form.It is supposed to redirect the user to another page after

email is sent.

 

Here's my code:

 

 

<?php

if(isset($_POST['submit'])) {

 

$to = "[email protected]";

$subject = "Form Tutorial";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$message = $_POST['message'];

 

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

 

echo "";

mail($to, $subject, $body);

 

 

 

// Change to the URL you want to redirect to

$URL="http://www.jondoe.org/thankyou.html";

 

header ("Location: $URL");

 

} else {

 

echo "blarg!";

 

}

?>

 

If you can help me figure this out I would be happy.

 

ps-real email and website name changed to protect the innocent.

Link to comment
https://forums.phpfreaks.com/topic/70579-solved-email-form-redirect/
Share on other sites

i get the warning

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/y/g/mygiftncf/html/mailerwebmaster.php:2) in /home/content/m/y/g/mygiftncf/html/mailerwebmaster.php on line 23

 

I recieved the email but it doesn't redirect to my page

Check this out.

 

<?php
$to = "[email protected]";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo "";
mail($to, $subject, $body);



// Change to the URL you want to redirect to
$URL="http://www.jondoe.org/thankyou.html";

header ("Location: $URL");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.