phpnewbieca Posted December 17, 2014 Share Posted December 17, 2014 Help! HTML5 Submit button not calling PHD file My HTML: <html> <head> </head> <body> <form action="my.php" method="POST" name="process_form"> <Input type="submit" name="submit" value="Submit" formmethod="post" formaction="my.php"> </form> </body> </html> PHP if(isset ($_POST["submit"])){ Do something; Do something; } else { Do something; Do something; } I click the button and nothing happens. What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/ Share on other sites More sharing options...
hansford Posted December 17, 2014 Share Posted December 17, 2014 (edited) The code works for me, not well-formed and formatted html and php code, but it works. Try setting some error reporting at the beginning of your php file - in case you have error reporting turned off. my.php <filename> <?php // used when debugging code only error_reporting(E_ALL); ini_set('display_errors', 1); if(isset ($_POST["submit"])){ // Do something; // Do something; echo 'isset'; } else { // Do something; // Do something; echo 'not isset'; } Edited December 17, 2014 by hansford Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1499810 Share on other sites More sharing options...
mac_gyver Posted December 17, 2014 Share Posted December 17, 2014 define: nothing happens? does the browser seem to stay on the html page? is there a chance that your my.php code redirects back to the html page? is the html and the php code in fact on the same/one page? does the browser goto the my.php page, but the page is blank? is that all the code you have in the html or is there some jaffascript (intentional play on words related to my avatar, haha) that could be interfering with the submission of the form? in order to help you with any coding problem, we need to know what your actual code is, what output/result you got from that code (stating that something 'doesn't work' or 'nothing happens' can have multiple meanings and what you observed must be specifically stated or shown), and what you expected the output/result to be (which we can generally deduce if we see your actual code.) also, if your client-side code doesn't reference the form by name, the <form> tag doesn't need the name='...' attribute and if you are not overriding the method or action attribute that's already present in the <form> tag, your <input> tag doesn't need the formmethod="..." and formaction="..." attributes. these are optional things. don't take the time to type them in if they are not being used. they just clutter up the code and increase the chances of errors that you will have to troubleshoot (which may be why nothing appeared to have happened when you tried to submit the form.) Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1499821 Share on other sites More sharing options...
phpnewbieca Posted December 21, 2014 Author Share Posted December 21, 2014 1. The browser (Firefox 34.04) stays on the html page. 2. html and php are separated files. Questions: 1. Would Registered Globals off cause this problem? 2. Would accessing html page from mobile device prevent submit button from working? <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> Replace or Upgrade Service Order </title> </head> <body bgcolor="#000080"> <form action="test.php" method="POST"> <table align="center" width="668"> <tr> <td align="center"> <font size="+3" color="#ffff00"> <b>~ ~ Replace or Upgrade Service Order ~ ~</b> </font> </td> </tr> </table> <br> <table width="668" align="center"> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffffff"> <b>* </b> </font> </td> <td align="left" valign="middle" colspan="1"> <font color="#ffffff"> <b>Required Fields</b> </font> </td> </tr> </table> <table width="668" align="center"> <tr> <td align="right" valign="middle" colspan="1" width="170"> <font color="#fffff00"> <b>Age Verification: * </b> </font> </td> <td align="left" valign="middle" colspan="1"> <INPUT type="radio" name="Eighteen" Value="Yes"> <font color="#ffffff"> {Note 1 at bottom of page} </font> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Type Order: * </b> </font> </td> <td align="left" valign="middle" colspan="1"> <font color="#ffff00"> New </font> <INPUT type="radio" name="List_2" VALUE="New"> <font color="#ffff00"> Revised </font> <INPUT type="radio" name="List_2" VALUE="Revised"> <font color="#ffffff"> {Note 2 at bottom of page} </font> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Confirmation #: * </b> </font> </td> <td align="left" valign="middle" colspan="1"> <INPUT type="text" name="confirmation_2" size="10" maxlength="10"> <font color="#ffffff"> {Note 3 at bottom of page} </font> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Type Service: * </b> </font> </td> <td align="left" valign="middle" colspan="1"> <font color="#ffff00"> Replace </font> <INPUT type="radio" name="List" VALUE="Replace"> <font color="#ffff00"> Upgrade </font> <INPUT type="radio" name="List" VALUE="Upgrade"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Date Service Needed: * </b> </font> </td> <td align="left" valign="middle" colspan="1"> <input type="text" name="Dsn" size="10" maxlength="10"> <font color="#ffffff"> {Format: mm-dd-yyyy} </font> <select size="1" name="Hour"> <option value="" selected>[Time]</option> <option value="7:00AM"> 7:00AM</option> <option value="7:30AM"> 7:30AM</option> <option value="8:00AM"> 8:00AM</option> <option value="8:30AM"> 8:30AM</option> <option value="9:00AM"> 9:00AM</option> <option value="9:30AM"> 9:30AM</option> <option value="10:00AM"> 10:00AM</option> <option value="10:30AM"> 10:30AM</option> <option value="11:00AM"> 11:00AM</option> <option value="11:30AM"> 11:30AM</option> <option value="12:00PM"> 12:00PM</option> <option value="12:30PM"> 12:30PM</option> <option value="1:00PM"> 1:00PM</option> <option value="1:00PM"> 1:30PM</option> <option value="2:00PM"> 2:00PM</option> <option value="2:30PM"> 2:30PM</option> <option value="3:00PM"> 3:00PM</option> <option value="3:30PM"> 3:30PM</option> <option value="4:00PM"> 4:00PM</option> <option value="4:30PM"> 5:30PM</option> <option value="5:00PM"> 5:00PM</option> <option value="5:30PM"> 5:30PM</option> <option value="6:00PM"> 6:00PM</option> </SELECT> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Title: </b> </font> </td> <td align="left" valign="top" colspan="1"> <select name="Title" size="1" > <option value="" selected>Please choose</option> <option value="Mr."> Mr.</option> <option value="Ms."> Ms.</option> <option value="Mrs."> Mrs.</option> </SELECT> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>First Name: * </b> </font> </td> <td align="left" valign="top" colspan="1"> <input type="text" name="Fname" size="30" maxlength="30"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Last Name: * </b> </font> </td> <td align="left" valign="top" colspan="1"> <input type="text" name="Lname" size="30" maxlength="30"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Suffix: </b> </font> </td> <td align="left" ="top" colspan="1"> <select name="Suffix" size="1"> <option value="" selected>Please choose</option> <option value="Sr."> Sr.</option> <option value="Jr."> Jr.</option> <option value="III"> III</option> <option value="IV"> IV</option> <option value="V"> V</option> </select> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Address: </b> </font> </td> <td align="left" valign="top" colspan="1"> <input type="text" name="Address" size="40" maxlength="40"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>City/State: * </b> </font> </td> <td align="left" valign="top" colspan="1"> <select name="CityState" size="1"> <option value="" selected>Please choose</option> <option value="Fairfield, CA"> Fairfield, CA</option> <option value="Suisun City, CA"> Suisun City, CA</option> <option value="Vallejo, CA"> Vallejo, CA</option> </select> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Zip Code: </b> </font> </td> <td align="left" valign="top" colspan="1"> <input type="text" name="Zip" size="5" maxlength="5"> <font color="#ffffff"> {Format: 99999} </font> </td> </tr> </table> <table width="667" align="center"> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Email Address: * </b> </font> </td> <td align="left" valign="top" colspan="1" width="492"> <input type="text" name="Email" size="54" maxlength="54"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="170"> <font color="#ffff00"> <b>Telephone: * </b> </font> </td> <td align="left" valign="top" colspan="1" width="492"> <input type="text name="Phone" size="12" maxlength="12"> <font color="#ffffff"> {Format: 999-999-9999} </font> </td> </tr> </table> <br> <table width="668" align="center"> <tr> <td align="center"> <font size="+2" color="#ffffff"> <b>Computer Information</b> </font> <br><br> </td> </tr> </table> <table width="668" align="center"> <tr> <td align="right" valign="middle" colspan="1" width="159"> <font color="#ffff00"> <b>Type: </b> </font> </td> <td align="left" valign="top" colspan="1" width="150"> <font color="#ffff00"> Desktop </font> <INPUT TYPE="radio" NAME="TypeComputer" VALUE="Desktop"> <font color="#ffff00"> Laptop </font> <INPUT TYPE="radio" NAME="TypeComputer" VALUE="Laptop"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="165"> <font color="#ffff00"> <b>Brand: </b> </font> </td> <td align="left" valign="top" colspan="1" width="492"> <input type="text" name="ComputerBrand" size="40" maxlength="40"> </td> </tr> <tr> <td align="right" valign="top" colspan="1" width="165"> <font color="#ffff00"> <b>Model: </b> </font> </td> <td align="left" valign="top" colspan="1" width="492"> <input type="text" name="ComputerModel" size="40" maxlength="40"> </td> </tr> </table> <br> <table width="668" align="center"> <tr> <td align="center" valign="top" colspan="1" width="667" > <font color="#ffffff" size="+2"> <b>Items to be Replaced or Upgraded</b> </font> <br> <font color="#ffff00"> <b>{Notes 4 and 5 at bottom of page}</b> </font> <br> </td> </tr> </table> <br> <table width="668" align="center"> <tr> <td align="left" colspan="1" width="167"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="Dvd"> <font color="#ffff00"> <b>DVD</b> </font> </td> <td align="left" colspan="1" width="167"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="Dvd_rw"> <font color="#ffff00"> <b>DVD+RW</b> </font> </td> <td align="left" colspan="1" width="290"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="HardDrive"> <font color="#ffff00"> <b>Hard drive</b> </font> </td> </tr> <tr> <td align="left" colspan="1" width="290"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="Memory"> <font color="#ffff00"> <b>Memory</b> </font> </td> <td align="left" colspan="1" width="167"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="ModemCard"> <font color="#ffff00"> <b>Modem Card</b> </font> </td> <td align="left" colspan="1" width="191"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="MultimediaCard"> <font color="#ffff00"> <b>Multimedia Card</b> </font> </td> </tr> <tr> <td align="left" colspan="1" width="290"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="NetworkCard"> <font color="#ffff00"> <b>Network Card</b> </font> </td> <td align="left" colspan="1" width="167"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="Software"> <font color="#ffff00"> <b>Software</b> </font> </td> <td align="left" colspan="1" width="191"> <input type="checkbox" name= "ReplaceUpgrade[]" size="1" maxlength="1" value="SoundCard"> <font color="#ffff00"> <b>Sound Card</b> </font> </td> </tr> <tr> <td align="left" colspan="1" width="290"> </td> <td align="left" colspan="1" width="290"> <input type="checkbox" name="ReplaceUpgrade[]" size="1" maxlength="1" value="Speakers"> <font color="#ffff00"> <b>Speakers</b> </font> </td> <td align="left" colspan="1" width="191"> </td> </tr> </table> <br><br> <table width="668" align="center"> <tr> <td align="center" valign="middle" colspan"1" width="165"> <font size="+2" color="#ffffff"> <b>Comments</b> </font> <br> <textarea name="Comments" rows="8" cols="60" wrap="physical"></textarea> </td> </tr> </table> <br> <table width="668" align="center"> <tr> <td align="center" width="668"> <input type="submit" value="Submit Form"> </td> </tr> </table> <br><br> <table align="left" width="850" border="10"> <tr> <td align="left" width="850"> <font color="#ffffff" size="+1"> <b>Notes:</b> </font> <font color="#ffff00" size="+1"> 1. <i><u><b>You</u> must be 18 or older to submit an order.</i></b> </font> </td > </tr> <tr> <td align="left" width="850"> <font color="#ffff00" size="+1"> <i><b> By selecting Age 'Verification' above you are affirming you are at least 18 years of age.</i></b> </font> </td> </tr> <tr> <td align="left" width="850"> <font color="#ffffff" size="+1"> <b> 2. Confirmation number for <i><u>New Order will 'Appear'</i></u> when you <u><i>'Submit'</i></u> your order.</b> </font> </td> </tr> <tr> <td align="left" width="850"> <font color="#ffff00" size="+1"> <b>3. Confirmation number is <u><i>'REQUIRED' for 'Revised Order'</i></u></b> </font> </td> </tr> <tr> <td align="left" width="850"> <font color="#ffffff" size="+1"> <b>4. <i>Hardware</i> -- Diagnose, Replace or Upgrade</b> </font> </td> </tr> <tr> <td align="left" width="850"> <font color="#ffff00" size="+1"> <b>5. <i>Software</i> -- Install/Setup or Upgrade</b> </font> </td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1500261 Share on other sites More sharing options...
ginerjm Posted December 21, 2014 Share Posted December 21, 2014 Why did you bother to post all that pure (bad) html code? It doesn't help us if you previous example matches this one in substance. There is no php in it so what does this post do? BTW - your submit button doesn't have a name. How is your php code supposed to properly recognize that YOU submitted the form? Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1500265 Share on other sites More sharing options...
mac_gyver Posted December 21, 2014 Share Posted December 21, 2014 the actual code you posted for your form does not have the same html markup for the submit button that you supplied in the first post in this thread. your form is submitting (just tested) to the action page, but that page is likely redirecting back to your form since it doesn't see that there is any name='submit' field present in the form data. a little debugging on your part would have found that the test.php page is actually being requested. here's your free lecture to go along with your free programming help - programming is an exact science. every character you type in your code matters and often the letter-case of those characters matter. we only see the information you post and when you adulterate the information you post so that it doesn't match your actual code, we cannot possibly help you. the form page you posted contains over 250 html markup errors. you need to use css instead of all the obsolete elements and attributes. most of the markup errors were due to using obsolete styling, and the page is certainly not coded to the html5 specification. 1 Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1500282 Share on other sites More sharing options...
phpnewbieca Posted December 21, 2014 Author Share Posted December 21, 2014 Just, what I needed 'Constructive Criticism'. I will rewrite r he code to meet html5 specifications. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1500291 Share on other sites More sharing options...
phpnewbieca Posted January 1, 2015 Author Share Posted January 1, 2015 Thank you for the error checking suggestion. Bad code is something newbies sometimes post during the learning process. Mistakes can be the best teacher. Thanks for the encouragement. Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1501404 Share on other sites More sharing options...
Solution phpnewbieca Posted January 4, 2015 Author Solution Share Posted January 4, 2015 There is a nice tool to check markup html:3C Internationalization Checker Is your page world ready? http://validator.w3.org/i18n-checker/ :-) Quote Link to comment https://forums.phpfreaks.com/topic/293140-html5-submit-button-not-calling-php-file/#findComment-1501738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.