Mulgard Mulgard - 6 months ago 8
PHP Question

PHP: Confirmation Dialog without using JavaScript?

I have a very simple form:

<form action="system/web/push.php" method="post">
<div class="row">
<div class="col card_input_push card_input_push_language">
<select name="<?php echo PARAM_PUSH_LANGUAGE; ?>">
<?php echo get_languages($mysqli); ?>
</select>
</div>
</div>
<div class="row">
<div class="col card_input card_input_push">
<input type="text" name="<?php echo PARAM_PUSH_TITLE; ?>" placeholder="<?php echo $language_array[LV_PUSH_INPUT_TITLE]; ?>"<?php echo set_value(PARAM_PUSH_TITLE); ?>required/>
</div>
</div>
<div class="row">
<div class="col card_input_push card_input_push_message">
<textarea name="<?php echo PARAM_PUSH_MESSAGE; ?>" placeholder="<?php echo $language_array[LV_PUSH_INPUT_MESSAGE]; ?>"<?php echo set_value(PARAM_PUSH_MESSAGE); ?>required></textarea>
</div>
</div>
<div class="row">
<div class="col text-center card_input_push card_button_push_send">
<button class="btn btn-default" type="submit" name="<?php echo REQUEST_SEND_GCM; ?>" value="<?php echo $language_array[LV_PUSH_INPUT_SEND]; ?>"><?php echo $language_array[LV_PUSH_INPUT_SEND]; ?></button>
</div>
</div>
</form>


When i now press the submit button i dont want the post to perform instantly. I first want a confirmation dialog to show up with yes or no answers and only if the user says
yes
i want the post action to be performed.

What i NOT want is to use
JavaScript
. Is there a way to do that?

EDIT

Thank's for the answers. To satisfy all respondents i would like to tell you, why i dont want to use
JavaScript
. The answer is simple. I have no idea about
JavaScript
. I never have used it before but the project im working on (as always) has to be finished ASAP. That's the only reason.

K.I K.I
Answer

Yes there is a way, use GET (not POST) the first time, on the PHP file check if GET was used and if so generate a form that sends confirmation form back to the user. Then make confirmation form to submit using POST and you are done.

 if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    // generate confirmation form
 }elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // process your data
 }

If anyone has access to a book called Head First PHP-MySQL they cover a similar example on page 280.

Comments