Swobbleton Swobbleton - 3 years ago 77
PHP Question

How to get a popup box after submitting a form?

[SOLVED] Thanks everyone that replied.

I've got a PHP script that is run after a user submited a contact form.
This script shows a message in the top left corner saying if it worked properly or if it encountered a problem.

Now my question is, how can I put those messages into a popup box?
I know there is JS involved, but I barely have knowledge of that.

( Example: http://www.dylanvanheugten.nl/contact.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>';


<form method="post" action="contact.php">
<input name="name" placeholder="Naam">

<input name="email" type="email" placeholder="Email">

<input name="subject" placeholder="Onderwerp">

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

Answer Source

Enclose your echo with <script> tags like this.

echo '<script>alert("Alstublieft alle velden invullen");<script>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download