LOUDMOUTH Posted June 25, 2009 Share Posted June 25, 2009 How can I block blank entries from this input box <input type='text' name='name' maxlength='15' value='$user_class->username'> <input type='submit' name='submit' value='Save Preferences'> Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/ Share on other sites More sharing options...
Ken2k7 Posted June 25, 2009 Share Posted June 25, 2009 What do you mean by block? You can check against empty. Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863156 Share on other sites More sharing options...
LOUDMOUTH Posted June 25, 2009 Author Share Posted June 25, 2009 Yeah I wanted to keep people from pressing the Submit button and changing the info to blank in the DB thank you Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863164 Share on other sites More sharing options...
Alex Posted June 25, 2009 Share Posted June 25, 2009 Within your php file that processes the information do something like.. if(!empty($_POST['name'])) { //Update the DB } else { echo 'You didn\'t enter a name.'; } Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863169 Share on other sites More sharing options...
Ken2k7 Posted June 25, 2009 Share Posted June 25, 2009 Yeah I wanted to keep people from pressing the Submit button and changing the info to blank in the DB thank you Use JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863171 Share on other sites More sharing options...
Alex Posted June 25, 2009 Share Posted June 25, 2009 Yeah I wanted to keep people from pressing the Submit button and changing the info to blank in the DB thank you Use JavaScript. Yea, but technically he said "AND changing the info to black in the DB". So if you use server-side validation they're not submitting and updating the DB Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863173 Share on other sites More sharing options...
Ken2k7 Posted June 25, 2009 Share Posted June 25, 2009 Of course you have to do server-side validation in case JavaScript is turned off. Quote Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863175 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.