0

hi everyone

i need a help in my php project with mysql database connection. I have a form that contains Fname, lname, contact and my problem is when i press the submit button without filling up the form the query will execute which inserts the blank data to my database.

5
Contributors
5
Replies
27
Views
4 Years
Discussion Span
Last Post by Webville312
0

You are going to need to do some "if(empty($something))" checks on your post data. To give you really any more information we would need to acctually see what your code looks like.

-1

HI,
What you need to do is,
Just add one condition before calliing to the Command Query or you can use validation funcations.
EG:

if(txt.text=txt2.text=txt3.text == '')
{

}
   ErrorMessage("Insert Value First")

else
{
    Your DB Command
}

------------------------------------------
Hope I am clear and it will work for you.

-1

You check to see if the submit button is used before running the form.
$submit = $_POST[submit]
and then

if(isset($submit)) {
    /* Code to run */
}

Edited by New-Reign: Incorrect spelling

0

Just do a check using if;

if($_POST['firstName'] == "" || $_POST['lastName'] =="")
{
echo "All fields have to be filled";
}
else 
{
//Run the submit code
}

That should work

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.