Group,
I'm attempting to use the e-mail validation on a form post processing
page. But, I'm such a newbie that I'm not sure how to get this to
work. My php code is included below. How would I actually validate
the $email variable because everything I've tried has failed.
?php
session_start();
include("address to database connection here");
$db_name = "ContEd";
$table_name = "Students";
$SSN = check_input($_POST[SSN]);
$Fname = check_input($_POST[Fname],"Please enter your first name.");
$Mname = check_input($_POST[Mname],"Please enter your middle name.");
$Lname = check_input($_POST[Lname],"Please enter your last name.");
$OtherNames = check_input($_POST[OtherNames]);
$Street = check_input($_POST[Street],"Please enter your mailing
address.");
$City = check_input($_POST[City],"Please enter your city.");
$State = check_input($_POST[State]);
$Zip = check_input($_POST[Zip],"Please enter your 6-digit zip code.");
$DOB_month = check_input($_POST[DOB_month]);
$DOB_day = check_input($_POST[DOB_day]);
$DOB_year = check_input($_POST[DOB_year]);
$Gender = check_input($_POST[Gender]);
$Hispanic = check_input($_POST[Hispanic]);
$Ethnic = check_input($_POST[Ethnic]);
$Hphone = check_input($_POST[Hphone],"Please enter a phone number.");
$Wphone = check_input($_POST[Wphone]);
$CellPhone = check_input($_POST[CellPhone]);
$email = ($_POST[email]);
$EducLevel = check_input($_POST[EducLevel]);
$EmpStatus = check_input($_POST[EmpStatus]);
$LEStatus = check_input($_POST[LEStatus]);
$LEOName = check_input($_POST[LEOName]);
$Comments = check_input($_POST[Comments]);
$connection = mysql_connect ($web_name, $web_user,$web_pass) or die
("Couldn't connect.");
$db = mysql_select_db ($db_name, $connection) or die ("Couldn't select
database.");
$query = "
INSERT INTO Students (SSN, Fname, Mname, Lname, OtherNames, Street,
City, State, Zip, DOB_month, DOB_day, DOB_year, Gender, Hispanic,
Ethnic, Hphone, Wphone, CellPhone, email, EducLevel,
EmpStatus, LEStatus, LEOName, Comments)
VALUES ('$SSN', '$Fname', '$Mname', '$Lname', '$OtherNames',
'$Street', '$City', '$State', '$Zip', '$DOB_month', '$DOB_day',
'$DOB_year',
'$Gender', '$Hispanic', '$Ethnic', '$Hphone', '$Wphone',
'$CellPhone', '$email', '$EducLevel', '$EmpStatus', '$LEStatus',
'$LEOName', '$Comments')
";
$result = @mysql_query($query, $connection) or die("Couldn't add to:
$db_name, $table_name.");
header('Location:
http://www.blueridge.edu/files/coned_thank_you.php');
function check_input($data, $problem = '')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
die($problem);
}
return $data;
}
?>