SeanF Posted July 5, 2023 Share Posted July 5, 2023 I have a form which has been working perfectly well for one user for a couple of years. Now, I have added a new user and the form fails for that one user. (I can't see a difference in user configuration.) The problem is that when the form is submitted using the following button: Quote <input type='submit' name='submit' value='Next'> The form is submitted but it returns with no values set and does not process any of the form data. Even echoing out $_POST['submit'] returns a null value I have placed the following code at the top of the page: Quote $test = $_POST['test']; echo "test: $test<br/>"; And then placed the following code in the body of the form: Quote echo "Hidden Test is here: <br/> <input type='hidden' name='test' value='Test'>"; When the page first loads "test" is NULL as one would expect. If I place the "test" hidden input element at the top of the form and click "Next" the value of test is "Test"... correct If I place the "test" hidden input element at the bottom of the form and click "Next" the value of test is NULL By moving the hidden input I have found that there is a specific part of the form which is causing a problem. If the input element is before the code, "test" has a value. If it is after that code, "test" is null. The offending code is here: Quote echo " <p>Please indicate below your space preferences below. </p> <table border=$table_border> <tr> <td>1st Choice: <input type='text' name='first_choice' size=15 maxlength=25> </td> <td>2nd Choice: <input type='text' name='second_choice' size=15 maxlength=25> </td> <td>3rd Choice: <input type='text' name='third_choice' size=15 maxlength=25> </td> </tr> <tr> <td colspan='3'> We would prefer <b><i>to</i></b> exhibit next to the following companies: <input type='text' name='next_to' size=50 maxlength=75> </td> </tr> <tr> <td colspan='3'> We would prefer <b><i>not to</i></b> exhibit next to the following companies: <input type='text' name='not_next_to' size=50 maxlength=75> </td> </tr> </table> "; I can't for the life of me figure out why this is causing a problem. Any thoughts would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/ Share on other sites More sharing options...
Barand Posted July 6, 2023 Share Posted July 6, 2023 If that is the offending code, where is the hidden "test" input of which you speak? You need to post the whole of the code for the form, from <form> to </form> Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610295 Share on other sites More sharing options...
SeanF Posted July 6, 2023 Author Share Posted July 6, 2023 1 hour ago, Barand said: If that is the offending code, where is the hidden "test" input of which you speak? You need to post the whole of the code for the form, from <form> to </form> The "test" input is in the quote box immediately following "And then placed the following code in the body of the form:" I place that echo statement either immediately before or immediately after the echo statement which is the "offending code" when the "input" is before the "offending code" all $_POST variables are set as expected. When the "input" is after, all of the $_POST['test'] is null as are all the $_POST variables from that point on Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610297 Share on other sites More sharing options...
mac_gyver Posted July 6, 2023 Share Posted July 6, 2023 your resulting html markup is broken, due to something like the out of date border = attribute value. you need to use modern markup and you need to validate the resulting web pages at validator.w3.org Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610298 Share on other sites More sharing options...
SeanF Posted July 6, 2023 Author Share Posted July 6, 2023 Great. Thank you for pointing out the validator site. This is old code from an application I wrote about 18 years ago and there is a LOT of outdated syntax. I have a lot of work to do but at least now I know where to start. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610302 Share on other sites More sharing options...
gizmola Posted July 6, 2023 Share Posted July 6, 2023 Along with validation, using the developer tools is an excellent iterative way to explore the state of the DOM, and to find syntax errors in javascript, or to explore layout and effective styles. The network tab is also extremely valuable, in examining request/response data for ajax or regular form processing via get or post requests. That should always be your first step in starting to debug things. Most modern code editors people use to develop PHP with will also catch a lot of syntax errors, although code that renders html will typically look valid so long as the php code is valid. Moving html into a template engine, or even making use of heredoc and nowdoc is helpful in many ways to separate markup from your logical code. Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610306 Share on other sites More sharing options...
SeanF Posted July 9, 2023 Author Share Posted July 9, 2023 On 7/6/2023 at 9:41 AM, gizmola said: ... Most modern code editors people use to develop PHP with will also catch a lot of syntax errors, ... Thanks for the input. What would you suggest as a good editor for PHP coding? I have been using "BBedit" for years but I am sure there's a better editor that would help me. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610400 Share on other sites More sharing options...
gizmola Posted July 9, 2023 Share Posted July 9, 2023 If you can afford it, PHPStorm is pretty much the professional standard. A lot of people also use visual studio code, in combination with the "Intelephense" plugin. Intelephense provides a good number of features for free, but you can also license it for $20 to unlock the rest of the features, which I would highly recommend. Quote Link to comment https://forums.phpfreaks.com/topic/317055-missing-_post-array-values/#findComment-1610401 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.