Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 54 lines (44 sloc) 1.196 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<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);
$my_id=$_POST ['my_id'];
$fname=$_POST ['first_name'];
$lname=$_POST['last_name'];
$ini=$_POST ['initials'];
if(!filter_var("$fname", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " f_name is invalid";

die('Error ' . mysql_error());
}

if(!filter_var("$lname", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " l_name is invalid";

die('Error ' . mysql_error());
}
if(!filter_var("$ini", FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[a-zA-Z]+$/"))))
{
echo " Initials is invalid";

die('Error ' . mysql_error());
}
else
{

$sql="INSERT INTO me (my_id,first_name,last_name,initials)
VALUES
('$_POST[my_id]','$_POST[first_name]','$_POST[last_name]','$_POST[initials]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}

echo "1 record added";
}
mysql_close($con)
?>
Something went wrong with that request. Please try again.