RE: elseif

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You should probably replace $name == "" with strlen($name) < 1.
Also, you should probably used $error .= instead of $error = so that you can list all the errors instead of just the last one.

<>< Ryan


-----Original Message-----
From: Addison Ellis [mailto:addison@bellsouth.net]
Sent: Monday, January 27, 2003 5:26 PM
To: php-db@lists.php.net
Subject:  elseif


hello and thank you for your time.
	will the below work to check if one field or the other is 
filled in upon submission? either contact_phone or contact_email is 
required but not both. best, addison

$error = "";
if ($name == "")
	{
	$error = "$error<LI>You must enter a company name.</LI>";
	}
if ($address == "")
         {
         $error = "$error<LI>You must enter an address.</LI>";
         }
if ($city == "")
         {
         $error = "$error<LI>You must enter a city.</LI>";
         }
if ($state == "")
         {
         $error = "$error<LI>You must enter a state.</LI>";
         }
if ($zip == "")
         {
         $error = "$error<LI>You must enter a zip.</LI>";
         }
if ($contact_phone == "")
         {
         $error = "$error<LI>You must enter a contact phone number or 
email address.</LI>";
         }
elseif ($contact_email == "")
         {
         $error = "$error<LI>You must enter a contact phone number or 
email address.</LI>";
         }
if ($error == "")
	{
	$query = "insert into stores  set
-- 
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
addison@bellsouth.net
info@smipco.com
subsidiaries of small independent publishing co.
info@gloabaldog.com
info@momandpocentral.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux