How to get a popup box after submitting a form?

Swobbleton

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


PHP

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Site Contact';
$to = '[email protected]';
$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>
Shankar Damodaran

Enclose your echo with <script> tags like this.

echo '<script>alert("Alstublieft alle velden invullen");<script>';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to avoid URL $_GET variables after submitting a form with ajax?

How to get the sucess message in the same page after submitting the contact form?

Modal box on submitting a form

Clear the input box after submitting the form in Angular 4

How to close popup after submitting values in react native?

Form popup box error

Form clears after submitting

How to redirect user after submitting form with React

How to redirect website after submitting google form?

How can I get the form values to appear in the table after submitting?

How do I get errors which are handled serverside in a ajax error message after submitting a form?

Get the check box value after submitting a form

Alert confirmation box on submitting form

How to clean form after submitting ajax?

Open a popup after successfully submitting form

How to redirect after submitting form in php

How to display alert message after submitting form

Form not submitting after form validation

How can I insert a variable into the resulting url parameter string after submitting my GET form?

after submitting a form to email i get 2 email instead 1

How to open a bootstrap modal box after submitting a form by barcode scanner

How to show a success dialog box after submitting the form in html?

How to clean a form with stars in javascript after submitting?

open a popup window in mvc asp.net after submitting a form

How to get the bootstrap popup box in square box

How to get the success message in the same page after submitting the form?

How can i get data or pass a data from one page to another after submitting a form in reactjs

How to redirect after submitting form

How to reset the form in React after submitting?