Jump to content

Avoid insert if text field is empty - help pleaseee


princeofpersia

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.