Clarification of Question by
patarok-ga
on
15 Jul 2003 14:01 PDT
Hello,
Thank you for answering my question.I know I should close this
question but to tell you the truth I don't feel I have gotten my
$40.00 worth and I promise when I feel satisfied I will close it.
Here is the whole script:
<html>
<head><title>Empty fields</title></head>
<body>
<?php
$user="patarok";
$host="43.webmasters.com";
$password="siklonezoom";
$database="patarok";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server!");
$db = mysql_select_db($database,$connection)
or die ("Couldn't execute query!");
/* set up array of field labels */
$label_array = array ( "first_name" => "First Name",
"last_name" => "Last Name",
"country" => "Country",
"address1" => "Address1",
"address2" => "Address2",
"city" => "City",
"state" => "State",
"zip" => "Zip",
"zip2" => "Zip2",
"area_code1" => "Area Code1",
"phone_number" => "Phone Number",
"area_code2" => "Area Code2",
"cell_number" => "Cell Number",
"phone_outside_us" => "Phone Outside U.S",
"email" => "E-mail",
"DOB" => "Date of Birth",
"gender" => "Gender",
"eye_color" => "Eye Color",
"hair_color" => "Hair Color",
"weight" => "Weight",
"height" => "Height",
"shoe_size" => "Shoe Size",
"agent" => "Agent",
"sag" => "Sag");
foreach ($HTTP_POST_VARS as $key => $value)
{
/* check each field except middle name for blank fields */
if ( $value == "" )
{
if ($key != "address2" and $key != "email" and $key !=
"area_code2" and $key != "cell_number" and $key != "phone_outside_us"
and $key != "zip2")
{
$blank_array[$key] = "blank";
}
}
elseif ($key == "first_name" or $key == "last_name" or $key ==
"country" or $key == "city" or $key == "state" or $key == "eye_color"
or $key == "hair_color")
{
if (!ereg("^[A-Za-z' -]{1,50}$",$HTTP_POST_VARS[$key]) )
{
$bad_format[$key] = "bad";
}
}
elseif ($key == "phone_number" or $key == "cell_number" or
$key == "phone_outside_us")
{
if (!ereg("^[0-9)( -]{7,20}(([xX]|(ext)|(ex))?[
-]?[0-9]{1,7})?$",$HTTP_POST_VARS[$key]) )
{
$bad_format[$key] = "bad";
}
}
elseif ($key == "email")
{
if
(!ereg("^.+@.+\.(com|net|org)$",$HTTP_POST_VARS[$key]) )
{
$bad_format[$key] = "bad";
}
}
}
/* if any fields were not okay, display error message and form */
if (@sizeof($blank_array) > 0 or @sizeof($bad_format) > 0)
{
if (@sizeof($blank_array) > 0)
{
/* display message for missing information */
echo "<b>You didn't fill in one or more required fields. You
must enter:</b><br>";
/* display list of missing information */
foreach($blank_array as $key => $value)
{
echo " {$label_array[$key]}<br>";
}
}
if (@sizeof($bad_format) > 0)
{
/* display message for bad information */
echo "<b>One or more fields have information that appears to
be incorrect. Correct the format for:</b><br>";
/* display list of bad information */
foreach($bad_format as $key => $value)
{
echo " {$label_array[$key]}<br>";
}
}
/* redisplay form */
echo "<p><hr>
<form action='CHECKALL2.php' method='post'>
<center>
First Name:<input type='text' name='first_name' size=20
value='$first_name'><br><BR>
Last Name:<input type='text' name='last_name' size=20
value='$last_name'><br><BR>
Country:<input type='text' name='country' size=12
value='$country'><br><BR>
Address Line 1:<input type='text' name='address1' size=35
value='$address1'><br><BR>
Address Line 2:<input type='text' name='address2' size=35
value='$address2'><br><BR>
City:<input type='text' name='city' size=15 value='$city'>
State:<input type='text' name='state' size=2 value='$state'
maxlength=2> Zip:<input type='text' name='zip' size=5 value='$zip'
maxlenght=5>-<input type='text name='zip2' size=4 value='$zip2'
maxlength=4><BR><br>
Phone Number:<input type='text' name='area_code1' size=3
value='$area_code1' maxlength=3> <input type='text'
name='phone_number' size=7 value='$phone_number'maxlength=7><br><BR>
Cell Number:<input type='text' name='area_code2' size=3
value='$area_code2' maxlength=3> <input type='text' name='cell_number'
size=7 value='$cell_number' maxlength=7><br><BR>
Phone Number(if outside of U.S.):<input type='text'
name='phone_outside_us' size=10 value='$phone_outside_us'><br><br>
E-mail:<input type='text' name='email' size=15 value='$email'><BR><BR>
Date of Birth:<input type='text' name='DOB' value='mm\dd\yy' size=8
value='$DOB' maxlenght=8><br><BR>
Gender:<select name='gender' value='$gender'>
<option value='male' selected>male
<option value='female'>female
</select><br><BR>
Do you have an agent?<tab>Yes<input type='radio' name='agent'
value=yes>
No<input type='radio' name='agent' value=no checked><br><BR>
Are you SAG?<tab>Yes<input type='radio' name='sag' value=yes>
No<input type='radio' name='sag' value=no checked><br><br><BR>
Eye Color:<input type='text' name='eye_color' size=5
value='$eye_color'><br><BR>
Hair Color:<input type='text' name='hair_color' size=7
value='$hair_color'><br><BR>
Weight:<input type='text' name='weight' size=3 value='$weight'
maxlength=3><br><BR>
Height:<input type='text' name='height' size=5
value='$height'><br><BR>
Shoe Size:<input type='text' name='shoe_size' size=2
value='$shoe_size' maxlength=2><br><br><br><br>
<input type='submit' value='Proceed'>\n
</form>
</center>";
exit();
}
else
{
$query = "Insert Into Members
(first_name,last_name,country,address1,address2,city,state,zip,zip2,area_code1,phone_number,area_code2,cell_number,phone_outside_us,email,gender,eye_color,hair_color,weight,height,shoe_size,agent,sag,dob)
VALUES ('$first_name','$last_name','$country','$address1','$address2','$city','$state','$zip','$zip2','$area_code1','$phone_number','$area_code2','$cell_number','$phone_outside_us','$email','$gender','$eye_color','$hair_color','$weight','$height','$shoe_size','$agent','$sag','$DOB')";
$result = mysql_query($query)
or die ("Couldn't execute query.");
echo "New member added to database<br>";
}
?>
</body>
</html>
Please tell me what the problem may be so I can get on it right away.
Also I have taken the websites you told me about in consideration.
Thank you for your time and have a great day!