neex1233 Posted June 25, 2009 Share Posted June 25, 2009 I have a PHP script that updates a user, but if you don't enter a form, it sets the value to blank. Is there any way around this?? Link to comment https://forums.phpfreaks.com/topic/163705-how-to-keep-mysql-values-the-same/ Share on other sites More sharing options...
ldougherty Posted June 25, 2009 Share Posted June 25, 2009 I assume what you mean is that if a user doesn't enter anything into one of the fields on your form when they submit the value written to the database is blank and you don't want that to happen? There are many ways around this.. You could use javascript to make the form fields required, ie that cant be blank. You could use some error checking to make sure the field has data before writing the query. You could set the default value of the column in the table to something other than NULL so it doesn't come in blank. Link to comment https://forums.phpfreaks.com/topic/163705-how-to-keep-mysql-values-the-same/#findComment-863801 Share on other sites More sharing options...
neex1233 Posted June 25, 2009 Author Share Posted June 25, 2009 So could I do it so in PHP if they didn't set anything it would just keep it the same as it is? Link to comment https://forums.phpfreaks.com/topic/163705-how-to-keep-mysql-values-the-same/#findComment-863804 Share on other sites More sharing options...
ldougherty Posted June 25, 2009 Share Posted June 25, 2009 Explain what you mean, are they editing a form with preloaded values and if they don't update the values are being set to blank or what? Link to comment https://forums.phpfreaks.com/topic/163705-how-to-keep-mysql-values-the-same/#findComment-863809 Share on other sites More sharing options...
neex1233 Posted June 26, 2009 Author Share Posted June 26, 2009 They will be entering information into a form and if they do not enter any information in a form it will set that field as blank. Link to comment https://forums.phpfreaks.com/topic/163705-how-to-keep-mysql-values-the-same/#findComment-863820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.