[已解决]感谢所有回复的人。
我有一个在用户提交联系表单后运行的 PHP 脚本。此脚本在左上角显示一条消息,说明它是否正常工作或是否遇到问题。
现在我的问题是,如何将这些消息放入弹出框?我知道涉及到 JS,但我对此几乎一无所知。
(例如:http ://www.dylanvanheugten.nl/contact.php )
PHP
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Site Contact';
$to = 'info@dylanvanheugten.nl';
$subject = $_POST['subject'];
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '' && $subject != '' && $message != '') {
if ($human == '12') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Uw bericht is verzonden.<br/> U krijgt binnen 3 werkdagen een bericht terug.</p>';
} else {
echo '<p>Er is iets mis gegaan tijdens het versturen van uw bericht.<br/> Probeert u alstublieft nogmaals.</p>';
}
} else if ($_POST['submit'] && $human != '12') {
echo '<p>U heeft de spam preventie som foutief beantwoord.</p>';
}
} else {
echo '<p>Alstublieft alle velden invullen.</p>';
}
}
HTML
<form method="post" action="contact.php">
<label>Naam</label>
<input name="name" placeholder="Naam">
<label>Email</label>
<input name="email" type="email" placeholder="Email">
<label>Onderwerp</label>
<input name="subject" placeholder="Onderwerp">
<label>Bericht</label>
<textarea name="message" placeholder="Laat hier ook uw telefoonnummer achter als u telefonisch contact wilt."></textarea>
<label><strong>*Spam preventie*</strong><br/>Wat is 11+1?</label>
<input name="human" placeholder="11 + 1 =">
<input id="submit" name="submit" type="submit" value="Verzend">
<label><u>Alle velden zijn verplicht.</u></label>
</form>