handle no-button-is-pressed case in multi-step php form? -


i found question how use 2 submit buttons, , differentiate between 1 used submit form? answer use 2 differently named buttons

<input type="submit" name="publish" alt="publish" value=""/>  <input type="submit" name="save" alt="save" value=""/> 

and detect pressed by

<?php     if (isset($_post['publish'])) {         // publish-button clicked     }     elseif (isset($_post['save'])) {         // save-button clicked     } ?> 

i found in answer of question how can tell button clicked in php form submit? 1 should not this, because might happen no button clicked.

other ways submit form exist, , browsers/versions decide not send name/value of submit buttons in of these situations. example, many users submit forms pressing enter key when cursor/focus on text field. forms can submitted via javascript, more obscure methods.

and 1 should rather use

if ($_server['request_method'] === 'post') {     //something posted      if (isset($_post['publish'])) {         // publish-button clicked     } else {         // assume save-button clicked     } } 

1. question: browser not send name of submit button if press enter in textfield of form? checked mozilla, , in browser sending name of submit button.

2.question: want construct multi-step form in php going page 1 page 3. pages in same php file, , detect button page want go next, structure looks similar one:

<?php     if(isset($_post['button1']))     {      include 'page2.php';     }     elseif(isset($_post['button2']))     {       include 'page3.php';     }     else     {       include 'page1.php';     }   ?> 

since have forward , backward button, thinking of storing in $_session['current_page'] page user is, , when form submitted no button-value, proceed next page. however, seems bit complicated me. there shorter solution?

  1. as writer suggests, of number of bots, little-known user agents, experimental clients, scripts, script kiddies, programmers testing functionality via debugging tools, , adrian lamo.

  2. i suppose introduce hidden variables; could, alternatively, pass state via get. best thing introduce javascript force (almost valid) users push 1 of buttons , have server produce error page requests submitted without correct button. or, perhaps better yet , little more web 2.0, don't use multiple page forms, magic in client (via hiding , un-hiding sections of form, etc.) , submit "multi-part" form in 1 operation validation server.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -