mercredi 6 juillet 2016

Modal Pop up PHP to confirm

A user enters an address, that is verified. I verify it using PHP after a post.

Once an address is entered, while it may be an accurate one, before I continue with the script, I want the user to verify and confirm they want to use that specific address.

I have been looking for a modal php script to pop in the middle of the script execution to query the user if the address they want is the address shown.

Here is what I have tried:

html:

<form method=POST action="process.php">
<input type="text" name="address">
<input type="submit">
</form>

process.php:

<?
   // visit xyz.com and check address

   $verified_address = "123 4 st, nowhere, NY, 10001"

   if ($verified_address!="") {
echo '<body>
    <script type="text/javascript">var x=window.confirm("Is this the correct address: ' . $v_add . '?")</script>
      </body>';

    }

//the rest of the code
?>

This code pops the dialog box, and the user can click OK, but how does the php connect to the javascript mid-stream? If the user clicks OK, then I want the rest of the code to run. If they do not confirm, I want to send the user back to re-enter the address.

Aucun commentaire:

Enregistrer un commentaire