0

I have a html filee with some text input fields , radio buttons and select boxes. When a user submit the completed form It use POST and send these data to a mail script and then send the required email.

But now I want to add a confirmation page in between my main html file and mail script. Users have to be able to see the data they entered and there would be two buttons called proceed and back. Proceed will send the mail and back would take the user back to the html file.

I have searched for many solutions, but couldn't find a good solution. How can I do this using php. The problem here is I can get the data to the confirmation page, but then can't send it to the mail script if user click proceed.

1
  • I have another problem, It is a dynamic form. So the data is different from one another. One person might have a option named year, but another would have a option named school. So how can I manage this situation. I only want to show what is relavant to the user Mar 12, 2014 at 10:06

4 Answers 4

0

You can always use jQuery pop-up box plugin. If user clicks "Send mail", then confirmation box pops up with two buttons: "Proceed" and "Cancel". One of million plugins: http://www.projectshadowlight.org/jquery-easy-confirm-dialog/

0

If you want to use just php it can be done. On your page where you process the form to email it out you can use a simple if statement.

Eg.

 If(isset($_POST['submit'])){

  echo "make another form here that will be displayed that they have to submit to confirm"

 }

elseif(isset($_POST['confirm'])){

echo "they confirmed and here is where we put the code to send the email."

} 
else{

 echo "they did no click submit and we can use a header to send them back to the original page."


 }
0

You can done by this way.

In the confirmation page, the form's action attribute should be pointed to the mail script page. ie: <form action="mail.php">

And the buttons "Proceed" and "Cancel" should be like this:

<input type="submit" value="Proceed"/>

and

<input type="button" value="Cancel" onclick="window.location.href='main-file.html'"/>

Please note the button "type".

0

This might help

file message.php

<form action="preview.php" method="post">

    <input type="text" name="email">
    <input type="text" name="subject">
    <textarea name="message"></textarea>

    <input type="submit" value="Continue">
</form>

file preview.php

<form action="send.php" method="post">

    <input type="hidden" name="email" value="<?php echo $_POST['email'];?>">
    <input type="hidden" name="subject" value="<?php echo $_POST['subject'];?>">
    <input type="hidden" name="message" value="<?php echo $_POST['message'];?>">
    Email: <?php echo $_POST['email'];?>
    <br/>
    Subject: <?php echo $_POST['subject'];?>
    <br/>
    Message: <?php echo $_POST['message'];?>

    <input type="submit" value="Send">
    <a href="message.php" title="Back">Back</a>   
</form>

file send.php

<?php
if(isset($_POST['email'])){

    mail($_POST['email'],$_POST['subject'],$_POST['message'];
    echo 'Message sent successfully';     
}else{
    header('Location: message.php');
}
?>
5
  • This solution worked, but I have another problem, It is a dynamic form. So the data is different from one another. One person might have a option named year, but another would have a option named school. So how can I manage this situation. I only want to show what is relavant to the user Mar 12, 2014 at 10:05
  • You can apply check using "if" condition like <?php if(isset($_POST['subject'])) { ?> <input type="hidden" name="subject" value="<?php echo $_POST['subject'];?>"> <?php echo $_POST['subject']; } ?> Mar 12, 2014 at 10:42
  • Thank you very much. I solved it too. I have one last problem. This works fine on firefox. But chrome somehow caches some data and mess up the confirmation page. I there a solution? Mar 12, 2014 at 10:50
  • You should check 'isset' for every POST parameter if they are dynamic. Mar 12, 2014 at 11:19
  • Thank you very much. But it doesn't work when we use browser back and forward Mar 12, 2014 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.