Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

87 lines (73 sloc) 2.455 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);
$email=$_POST ['email_id'];
$mob=$_POST ['mobile_no'];
$oth=$_POST['other_phone'];
$addr=$_POST ['address'];
$city=$_POST ['city'];
$zip=$_POST ['zip'];
$add=$_POST ['neighbourhood'];
$web=$_POST ['website'];
if(!filter_var("$email", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,4}$/"))))
{
echo " email is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$mob", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/"))))
{
echo " mobile number is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$oth", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[0-9]+$/"))))
{
echo " phone number is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$addr", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/[a-zA-Z0-9_.-]+$/"))))
{
echo " address is invalid";
die('Error ' . mysql_error());
}
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("$zip", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[0-9][0-9][0-9][0-9][0-9][0-9]$/"))))
{
echo " Zip code is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$web", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z0-9.-_]+.[a-z]+$/"))))
{
echo " Website is invalid";
die('Error ' . mysql_error());
}
if(!filter_var("$add", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " Neighbourhood is invalid";
die('Error ' . mysql_error());
}
else
{
$sql="INSERT INTO contact_info (email_id,mobile_no,other_phone,c_id,address,city,zip,neighbourhood,website)
VALUES
('$_POST[email_id]','$_POST[mobile_no]','$_POST[other_phone]','$_POST[c_id]','$_POST[address]','$_POST[city]','$_POST[zip]','$_POST[neighbourhood]','$_POST[website]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
}
mysql_close($con)
?>
Jump to Line
Something went wrong with that request. Please try again.