Solved

Re-direct users after email script

Posted on 2008-10-01
6
221 Views
Last Modified: 2012-05-05
I have a PHP mail script (see below) that is working great.  However, at this time, when someone hits SEND on the HTML page, it just directs them to a blank white page, so they keep hitting back & send again.

What would it take in this PHP script to re-direct it to thankyou.html once they have submitted the form?

Thanks!
<?php
 
// Report PHP errors
error_reporting(E_ALL);
 
// Assign the variables
$requester = $_POST['requester'];
$phone = $_POST['phone'];
//$date = date(F j, Y);
$bdesc = $_POST['bdesc'];
$desc = $_POST['desc'];
$loc = $_POST['loc'];
$cdate = $_POST['cdate'];
$dept = $_POST['dept'];
$email = $_POST['email'];
 
// Mail
$static = "rusty.page@bioness.com";
$subject = $bdesc;
$body = "<strong>"."Requester's Name:     " ."</strong>". $requester . "<br>" . "<strong>". "Requester's Phone Number:     " ."</strong>". $phone . "<br>" ."<strong>"."Problem Description:     " ."</strong>". $desc . "<br>" . "<strong>"."Location:     " ."</strong>".$loc . "<br>" ."<strong>"."Date needed by:     "."</strong>" . $cdate . "<br>" ."<strong>". "Requester's Department:     " ."</strong>". $dept;
$headers = 
      "From: " . $email . "\r\n" . 
      "Reply-To: " . $email . "\r\n" . 
      "MIME-Version: 1.0" . "\r\n" . 
      "Content-type: text/html;charset=iso-8859-1" . "\r\n" .
      "X-Mailer: PHP/" . phpversion();
mail($static, $subject, $body, $headers);
 
 
?>

Open in new window

0
Comment
Question by:rustyrpage
  • 4
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
EMB01 earned 500 total points
ID: 22617747
All you should need to do is add this to your script:
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
0
 
LVL 6

Author Comment

by:rustyrpage
ID: 22617757
Do I put that at the very end of the script? (after the mail line)
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22617758
Note: Just add it to the end of the script.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Expert Comment

by:EMB01
ID: 22617761
Yeah, let me know if you need any more help.
0
 
LVL 6

Author Comment

by:rustyrpage
ID: 22617786
Pure genius!

Thanks again - you were so much help!
0
 
LVL 14

Expert Comment

by:EMB01
ID: 22617813
Hey, it's you putting it all together! By the way, let me know if you want to add validation. It's a little more tricky but we can do it. Have a great afternoon!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question