hanlonj Posted September 20, 2006 Share Posted September 20, 2006 Hi,I am validating a form on a page using the [code]$_SERVER[PHP_SELF}[/code]superglobal.I check for empty fields and display an error beside the field that is empty so the user will know what to correct (as per usual on a website).My problem is that when the page loads initially, the form is as you would expect empty. so the errors appear upon first loading of the page.I realise this is easy to fix but the solution is escaping me at the moment.Can anyone help?John Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 20, 2006 Share Posted September 20, 2006 that means, you are probably running your validation without ever seeing whether or not the form has been submitted. let's say you have your submit button simply named "submit", you'll need to wrap your entire validation and processing within something like this:[code]<?phpif (isset($_POST['submit'])) { // process your form here.}?>[/code] Quote Link to comment Share on other sites More sharing options...
hanlonj Posted September 20, 2006 Author Share Posted September 20, 2006 [quote author=obsidian link=topic=108839.msg438297#msg438297 date=1158784082]that means, you are probably running your validation without ever seeing whether or not the form has been submitted. let's say you have your submit button simply named "submit", you'll need to wrap your entire validation and processing within something like this:[code]<?phpif (isset($_POST['submit'])) { // process your form here.}?>[/code][/quote]Excellent, worked no problem.Thank you very much.John Quote Link to comment 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.