Find file
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (49 sloc) 1.4 KB
<HTML>
<HEAD>
<TITLE>Insert</TITLE>
</HEAD>
<BODY background="1.jpg" bgcolor="#333333>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("openspace", $con);
$high=$_POST ['high_school'];
$col=$_POST ['college'];
$emp=$_POST['employer'];
$oth=$_POST ['other_details'];
if(!filter_var("$high", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " High school is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$col", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " college is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$emp", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " employer is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$oth", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z0-9_.-]+$/"))))
{
echo " Details are invalid";
die('Error ' . mysql_error());
}
else
{
$sql="INSERT INTO education_work_info (high_school,college,e_id,employer,other_details)
VALUES
('$_POST[high_school]','$_POST[college]','$_POST[e_id]','$_POST[employer]','$_POST[other_details]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
mysql_close($con)
?>