如何弹出回声而不是在新标签中打开?

时间:2017-01-27 20:02:29

标签: php html forms

我创建了一个电子邮件表单,按下提交按钮后,我想要弹出一个窗口,而不是打开一个新选项卡。
这是形式:

<form name="contactform" method="post" action="send_form_email.php">
    <input class="inputForm" type="text" name="name" id="nameInput" placeholder="name*">
    <input class="inputForm" type="text" name="email" id="emailInput" placeholder="email*">
    <textarea name="message" placeholder="message*"></textarea>
    <input id="submitButton" type="submit" name="submit">
</form>  

这是它的PHP:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = "myemail@gmail.com";
$subject = "New message";

mail ($to, $subject, $message, "From: " . $name);
echo "Your message has been sent!";

?>

1 个答案:

答案 0 :(得分:0)

这在技术上是一个提醒,但是你走了!

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = "myemail@gmail.com";
$subject = "New message";

mail ($to, $subject, $message, "From: " . $name);
echo('<script>
alert("Your message has been sent!")
</script>')
?>

我认为这就是你所要求的,但如果你要求别的东西,我希望你能找到它!