Page 1 of 1

How to check empty form fields

Posted: Tue May 23, 2006 3:27 am
by Milan
Hi Cool and helpfull people,

I have a small problem (again) On the update user profile page i have a input field and a type='file' and i have seen that i cannot have a default value in it :( so now what happens is that since the form cannot assign a value to the textbox it leaves it blank. So when user submt the data, null will be saved in the the user_logo filed in the table instead of leaving the old value.

How can i check on submission if the textbox filed is empty and in that case do not modify the entry and in case the texbox is populated ( from a browse button) upload the file location and sve the file name in the database ( or just save the file name in the database if upload code will take time)

thanks again! I have always found help on this forum :)

Milan

Posted: Tue May 23, 2006 3:45 am
by someberry
Several ways:

Code: Select all

if($_POST['file'] === '')

Code: Select all

if(empty($_POST['file']))

Posted: Tue May 23, 2006 4:11 am
by JayBird
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
No need for a poll either