Hi

After a html form is dent a php processes the mail and if successful the mails is sent and a message tell the sender all is ok.

I want this message to appear but redirect after, say 5 second, to the page they came from (with the form) which is 1 page back.

I have this code, just under start <?php. It redirects immediately to the index page, with no message that the mail was sent. I think this is a little confusing for the sender.

Is there a way to do this?

header("Location: http://" . $_SERVER['HTTP_HOST']
                    . rtrim(dirname($_SERVER['PHP_SELF']), '/\\')
                    . "/" . $relative_url);

    redirect the user to a thank you page, and pass the message by $_SESSION or by an url.

    do not allow the user to wait 5 seconds before redirect. I can refresh the page and cause bulk email send by your processor page.

      Wow

      Didnt know this could be a problem.

      I will have to think again.

      Thanks

        How would I "redirect the user to a thank you page, and pass the message by $_SESSION or by an url"

        I guess I want to pass
        'name'
        'email'
        'subject'
        'message'

        If anyone could help, that would be great.

        This is the html code for the form...

        <form action='welcome.php' method='POST'>
        
        <label for='name'>Name:</label><input type='text' name='name' size="30">
          <br/>
        
         <label for='email'>Email:</label><input type='text' name='email' size="30">
          <br/>
        
           <label for='subject'></label> Property:<input type='text' name='subject' size="70" value="{$listing_title}">
          <br/>
        
          <label for='message'>Your Message:</label>
        
          <textarea name='message' rows="10" cols="40">
          <input type='submit' name='submit' value='Send'>
          </form>
          $_SESSION["post"]=$_POST;

          redirect....

          and in thankyou page you retrieve the entered values from this $_SESSION["post"]

          array with the normal indexxes you know. $_SESSION["post"]['name'] for example.

            Do I put the

            $_SESSION["post"]=$_POST; 

            in the "welcome.php" ? At the moment it looks like this...

            <?PHP
            $name = $_POST['name'];
            $email = $_POST['email'];
            $subject = $_POST['subject'];
            $message = 'NAME: ' . $name . "\n\n";
            $message .= 'EMAIL: ' . $email . "\n\n";
            $message .= 'PROPERTY: ' . $subject . "\n\n";
            $message .= 'MESSAGE: ' . $_POST['message'];
            $target_address = 'my-email-address';
            $headers = "From: ".$email."\r\n". "X-Mailer: php";
            if (mail($target_address, $subject, $message, $headers)) {
            echo ("Your message has been sent, the owner will contact you as soon as possible. Please hit the Back button to return to the property page.");
            }
            else{
            echo ("Sorry your message delivery failed. Please hit the back button, make sure all fields are complete and try again");
            die();
            }
            ?>

            Also, is it possible to use the "echo" the variables to return the relevant info on the same page...
            i.e. something like

            echo (Thank you 'name', your message... 'message' has been sent. You will be contacted shortly)

              instead of this:

              echo ("Your message has been sent, the owner will contact you as soon as possible. Please hit the Back button to return to the property page.");

              $_SESSION["post"]=$_POST;
              header("Location: index.php");
              die();

              And on the top of your page:

              if(isset($_SESSION["post"]))
              {
              echo "thank you message:"; // echo the indexes and summarize the entered values from $_SESSION["post"]
              unset($_SESSION["post"]); // unsert the posted values, on the next page load this message won't be shown.
              }

                That code just redirected me to the index page with no message that the mail was sent.

                For usability, I would like a message saying the mail was sent and take them back to the page where the form is on.

                I have this now...

                <?PHP
                if(isset($_SESSION["post"])) 
                { 
                echo "thank you message:"; // echo the indexes and summarize the entered values from $_SESSION["post"] 
                unsert($_SESSION["post"]); // unsert the posted values, on the next page load this message won't be shown. 
                }
                $name = $_POST['name'];
                $email = $_POST['email'];
                $subject = $_POST['subject'];
                $message = 'NAME: ' . $name . "\n\n";
                $message .= 'EMAIL: ' . $email . "\n\n";
                $message .= 'PROPERTY: ' . $subject . "\n\n";
                $message .= 'MESSAGE: ' . $_POST['message'];
                $target_address = 'my-email-address';
                $headers = "From: ".$email."\r\n". "X-Mailer: php";
                if (mail($target_address, $subject, $message, $headers)) {
                $_SESSION["post"]=$_POST; 
                header("Location: index.php"); 
                die(); 
                }
                else{
                echo ("Sorry your message delivery failed. Please hit the back button, make sure all fields are complete and try again");
                die();
                }
                ?>
                  Write a Reply...