Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
96 lines (79 sloc) 2.6 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);
$city=$_POST ['current_city'];
$town=$_POST ['hometown'];
$sex=$_POST['sex'];
$birth=$_POST ['birthday'];
$rel=$_POST ['relationship_status'];
$pol=$_POST ['political_views'];
$reli=$_POST ['religious_views'];
$bio=$_POST ['bio'];
$fav=$_POST ['favourite_quotations'];
if(!filter_var("$city", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " city is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$town", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " town is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$sex", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[mfmalefemale]+$/"))))
{
echo " sex is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$birth", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[0-9]+:[0-9]+:[0-9]+$/"))))
{
echo " Birth is Invalid ";
die('Error ' . mysql_error());
}
if(!filter_var("$rel", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " Status is Invalid ";
die('Error ' . mysql_error());
}
if(!filter_var("$pol", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " view is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$reli", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " view is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$bio", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z0-9]+$/"))))
{
echo " bio is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$fav", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " l_name is invalid";
die('Error ' . mysql_error());
}
else
{
$sql="INSERT INTO basic_info (current_city,hometown,sex,birthday,relationship_status,political_views,religious_views,bio,favourite_quotations,b_id)
VALUES
('$_POST[current_city]','$_POST[hometown]','$_POST[sex]','$_POST[birthday]','$_POST[relationship_status]','$_POST[political_views]','$_POST[religious_views]','$_POST[bio]','$_POST[favourite_quotations]','$_POST[b_id]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
mysql_close($con)
?>