Jump to content

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 = "jondoe@gmail.com";

$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 = "jondoe@gmail.com";
$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");
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.