i am trying to insert a value in a table but first the data i enter i check the pattern of the data entered using regular expressions
this is my code ..but it is working can anyone tell me the problem with my code please ?
<?php
extract($_POST);
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="rootpass"; // Mysql password
$db_name="myshop"; // Database name
$name=trim($Gname); //trimming the name
$pattern="/^[a-zA-Z]$/";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
if ($name=="")
echo ("Missing Info");
else
{
if (isset($name))
{
if (preg_match($pattern,$name))
$sql="INSERT INTO ayesha VALUES('$name')";
else
echo("wrong syntax");
}
else
{
echo("missing info");
}
?>