Second form submit capture issue - PHP -


hi can 1 give me clue why "form 2 here" message not displaying in following code? have written lengthy code in following structure. help

<doctype html> <html> <head><title></title> </head> <body> <div id="one" style="width:300px; background:gray;"> <form method="post" action="<?= $_server['php_self'] ?>"> <input type="text" name="txt1" id="txt1"> <input type="submit" name="sendone" id="sendone" value="one"> </form> </div>  <div id="two" style="width:300px; background:yellow;"> <?php if(isset($_post['sendone'])) {echo "<input type='submit' name='sendtwo' id='sendtwo' value='two'>";}  if(isset($_post['sendtwo'])) {echo "form 2 here!"; return;} ?> </div> </body> </html> 

in form have field 'sendone'. other 1 placed outside form.

as submit first form, insert second input field in html code, place outside form tags. that's why it's not in request when submit form second time. input fields should within opening , closing form tag in order processed.

you should place second form input within 'form' tags:

<doctype html> <html> <head><title></title> </head> <body> <div id="one" style="width:300px; background:gray;"> <form method="post" action="<?= $_server['php_self'] ?>"> <input type="text" name="txt1" id="txt1"> <?php if(isset($_post['sendone'])) {echo "<input type='submit' name='sendtwo' id='sendtwo' value='two'>";} ?> <input type="submit" name="sendone" id="sendone" value="one"> </form> </div>  <div id="two" style="width:300px; background:yellow;"> <?php if(isset($_post['sendtwo'])) {echo "form 2 here!"; return;} ?> </div> </body> </html> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -