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? Link to comment https://forums.phpfreaks.com/topic/93149-ensuring-all-text-feilds-contain-date/ 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. Link to comment https://forums.phpfreaks.com/topic/93149-ensuring-all-text-feilds-contain-date/#findComment-477197 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. Link to comment https://forums.phpfreaks.com/topic/93149-ensuring-all-text-feilds-contain-date/#findComment-477232 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. Link to comment https://forums.phpfreaks.com/topic/93149-ensuring-all-text-feilds-contain-date/#findComment-477264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.