Solved

Re-direct users after email script

Posted on 2008-10-01
6
216 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is best version of php to use 6 46
get domain with php 7 20
How to count in a table in php 22 18
php construct 5 7
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now