# Simulating a Redirect

**URL:** https://forum.kirupa.com/t/simulating-a-redirect/288788
**Category:** programming
**Created:** [May 21, 2009, 12:11am UTC](https://forum.kirupa.com/t/simulating-a-redirect/288788 "2009-05-21T00:11:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)
#### Post date: [May 21, 2009, 12:11am UTC](https://forum.kirupa.com/t/simulating-a-redirect/288788/1 "2009-05-21T00:11:41Z")

</div>

I have a form that when submitted sends an email, and stores the user’s information in a database. If the submit is successful I would like to send users to a “Thank You” page that has the appropriate look and feel of the website. I can’t use a header() function since the headers would already have been sent on the PHP script page. Is there another approach I can use?

```auto

if(@mail($to, $subject, $body, $header))
    {
        header( 'Location: http://www.mydowmain.com/_test/thankyou.html' ) ;
        //print ('<font size=\"2\"><b>Your Message Has Been Sent.<br>Thank You for Signing our Guestbook.</b><br><br>');
        //print("<a href=\"javascript:history.go(-1);\">Return to the form</a></font><br><br>");
        
    } else {
        print ('<font size=\"2\">Output Error: Please be sure to fill in all form fields.<br>');
        print("<a href=\"javascript:history.go(-1);\">Return to the form</a></font>");
    }
} else {
        print ('<font size=\"2\">Error! Form variables not received. Please be sure to fill in all form fields.<br>');
        print("<a href=\"javascript:history.go(-1);\">Return to the form</a></font>");
}

```
