revised: foreach($HTTP_POST_VARS...
| From: | Addison Ellis | Date: | Wed, 22 Jan 2003 18:19:05 +0000 |
| Subject: | revised: foreach($HTTP_POST_VARS... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-25044@lists.php.net to get a copy of this message | ||
hello,
i am trying to point all my forms to this .php file to check for errors, and if they are ok, insert the submitted form values into a table in a database.
if i use this: <? require("config.php"); $error = ""; if ($name == "") { $error = "$error<LI>You must enter a company name.</LI>"; } if ($address == ""){ $error = "$error<LI>You must enter an address.</LI>"; }can you tell me where to go from beyond the attached email below? below the code following i don't know where to go. do i need to list each value individually or can i do something with $HTTP_POST_VARS or am i even headed in the right direction?etc. and the form, say yardsale.php, doesn't have the field "name" in it, will it skip over that field or will it return an error saying "name" is blank? orforeach($HTTP_POST_VARS as $key => $value) { if ($key != "") { if ($value == "") { $message_new = "<font face=verdana size=1 color=red>Required information missing.\n Please try again.</font>"; } } if (ereg($key)) { if (!ereg("^[A-Za-z' -]{1,50}$",$key)) { $message_new = "<font face=verdana size=1 color=red>Some information not processing.\n Please try again.</font>"; } } $$key = strip_tags(trim($value)); } if (!ereg("^[0-9)(xX -]{7,20}$",$contact_phone)) { $message_new = "<font face=verdana size=1 color=red>Not a valid phone number.\n Please try again.</font>"; } if (!ereg("^.+@.+\\..+$",$contact_email)) { $message_new = "<font face=verdana size=1 color=red>Not a valid email address.\n Please try again.</font>";}elseif ($message == "") { $query = "insert into ad_columns 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(from here can i write something like $query = "foreach($HTTP_POST_VARS as $key => $value) insert into ad_columns set??? thank you. addison ellis