princeofpersia Posted December 26, 2010 Share Posted December 26, 2010 Hi guys I have the code below and have 4 text fields, the issue is i'd like to prevent insert query if textfield is empty, do u know how? if (isset($_POST['register']) && $_POST['register']) { $reference = rand(11111111,99999999); $name1 = addslashes(strip_tags($_POST['name1'])); $name2 = addslashes(strip_tags($_POST['name2'])); $name3 = addslashes(strip_tags($_POST['name3'])); $name4 = addslashes(strip_tags($_POST['name4'])); $addname4=mysql_query("INSERT INTO nearest (stref, name) VALUES('$reference','$name4')"); $addname3=mysql_query("INSERT INTO nearest (stref, name) VALUES('$reference','$name3')"); $addname2=mysql_query("INSERT INTO nearest (stref, name) VALUES('$reference','$name2')"); $addname1=mysql_query("INSERT INTO nearest (stref, name) VALUES('$reference','$name1')"); } thanks Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 26, 2010 Share Posted December 26, 2010 if (somevalue == "") { don't do anything } else { perform the inserts } Quote Link to comment Share on other sites More sharing options...
princeofpersia Posted December 26, 2010 Author Share Posted December 26, 2010 thanks, it works Quote Link to comment 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.