PHP邮件脚本确认

时间:2014-03-12 06:39:14

标签: php html email

我有一个包含文字input fieldsradio buttonsselect boxes的html文件。当用户提交完成的表单时,使用POST并将这些数据发送到邮件脚本,然后发送所需的电子邮件。

但现在我想在主html文件和邮件脚本之间添加一个确认页面。用户必须能够看到他们输入的数据,并且会有两个名为proceed和back的按钮。 Proceed将发送邮件,然后返回将用户带回html文件。

我已经搜索了很多解决方案,但找不到一个好的解决方案。我怎么能用php做到这一点。这里的问题是我可以将数据发送到确认页面,但如果用户点击继续,则无法将其发送到邮件脚本。

4 个答案:

答案 0 :(得分:0)

您可以随时使用jQuery弹出框插件。 如果用户点击"发送邮件",则会弹出确认框,其中包含两个按钮:"继续"和"取消"。 百万插件之一: http://www.projectshadowlight.org/jquery-easy-confirm-dialog/

答案 1 :(得分:0)

如果你想只使用php就可以完成。在您处理表单以通过电子邮件发送的页面上,您可以使用简单的if语句。

例如

 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."


 }

答案 2 :(得分:0)

你可以通过这种方式完成。

在确认页面中,应将表单的action属性指向邮件脚本页面。即:<form action="mail.php">

按钮&#34;继续&#34;和&#34;取消&#34;应该是这样的:

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

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

请注意按钮&#34;键入&#34;。

答案 3 :(得分:0)

这可能会有所帮助

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>

文件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');
}
?>
相关问题