burge124 Posted February 26, 2008 Share Posted February 26, 2008 hi, what method should i use to ensure when a user is registering to a system that all of the feilds contain some information, otherwise the page simply reloads or shows up an error message? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 26, 2008 Share Posted February 26, 2008 first, use the isset() function on the submit button to check if the submit was submitted (returns TRUE/FALSE). next use the empty() function to check if a filed was left empty (returns TRUE/FALSE). if any thing was empty display the page again. otherwise save the info, and use a header to go to the next page. Quote Link to comment Share on other sites More sharing options...
fnairb Posted February 26, 2008 Share Posted February 26, 2008 You can never trust the user so testing in your script is the right thing to do. However, if the option is available, do your users a favor and include that check on the client side as well before the GET/POST is submitted. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 26, 2008 Share Posted February 26, 2008 if you decide to use the empty function, you may want to replace all the spaces to check and make sure the user didn't just enter in a lot of spaces. <?php $testString = str_replace(" ",""$string); // don't save this just use it to check stuff. 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.