Jump to content

Simple php form question - How to redirect to page after submit?


emerson5000

Recommended Posts

Using the php form script below, I'd like the script to return the user to the original form page after they submit the form. 

 

Thx,

Emerson

_________________________________

<?

$subject="from ".$_GET['name'];

$headers= "From: ".$_GET['email'];

$headers.=$_GET['phone']. "\n";

$headers.='Content-type: text/html; charset=iso-8859-1';

mail("name@company.com", $subject,  "

 

  " ."Name: " .$_GET['name']."

 

  " ."Phone: " .$_GET['phone']."

 

  " ."Email: " .$_GET['email']."

 

  " ."Message: " .$_GET['message']."

 

</body>

</html>" , $headers);

echo ("Your message was sent!");

 

?>

<script>

___________________________

Link to comment
Share on other sites

You would need to use header('Location: http://www.example.com/');, do you want the redirect after the "Your Message Was Sent" text was seen or do you want to just redirect straight to a page?

 

Superfast responses!  Thanks to all!

 

tomtimms,

Once a user submits the form, I'd like to redirect them to the index page straight away.

 

I'm still doing something incorrectly. I added line 17 shown below but it doesn't redirect.

 

Emerson

 

________________________________

<?

$subject="from ".$_GET['name'];

$headers= "From: ".$_GET['email'];

$headers.=$_GET['phone']. "\n";

$headers.='Content-type: text/html; charset=iso-8859-1';

mail("myname@company.com", $subject,  "

 

  " ."Name: " .$_GET['name']."

 

  " ."Phone: " .$_GET['phone']."

 

  " ."Email: " .$_GET['email']."

 

  " ."Message: " .$_GET['message']."

 

header('location: http://www.company.com/index.html');

 

</body>

</html>" , $headers);

echo ("Your message was sent!");

 

?>

<script>

___________________________________

Link to comment
Share on other sites

Looks like you're putting the redirect inside you email message.  Put it in place of the "Your messages was sent" line.

<?
$subject="from ".$_GET['name'];
$headers= "From: ".$_GET['email'];
$headers.=$_GET['phone']. "\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("myname@company.com", $subject,  "

  " ."Name: " .$_GET['name']."

  " ."Phone: " .$_GET['phone']."

  " ."Email: " .$_GET['email']."

  " ."Message: " .$_GET['message']."

</body>
</html>" , $headers);

header("location: http://www.company.com/index.html");

?>

Link to comment
Share on other sites

Looks like you're putting the redirect inside you email message.  Put it in place of the "Your messages was sent" line.

<?
$subject="from ".$_GET['name'];
$headers= "From: ".$_GET['email'];
$headers.=$_GET['phone']. "\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("myname@company.com", $subject,  "

  " ."Name: " .$_GET['name']."

  " ."Phone: " .$_GET['phone']."

  " ."Email: " .$_GET['email']."

  " ."Message: " .$_GET['message']."

</body>
</html>" , $headers);

header("location: http://www.company.com/index.html");

?>

 

 

Drummin!  Rock-star!  Works perfectly!  Thanks amigo!

 

Link to comment
Share on other sites

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.