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'> 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. 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 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.'; } 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. 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 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. Link to comment https://forums.phpfreaks.com/topic/163589-blank-input-fields/#findComment-863175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.