Leave a comment

Handling Insert Query in MySql using PHP?

<form action=”planet.php” method=”get” style=”padding-left:20px;”>
ZipCode<input type=”text” name=”zip” maxlength=”10″ />
ZipArea<input type=”text” name=”area” maxlength=”20″ />
<input type=”submit” name=”submit” value=”Insert Zip” />
$zcode = $_GET[‘zip’];
$ziparea = $_GET[‘area’];
$submit = $_GET[‘submit’];

if(mysql_num_rows(mysql_query(“SELECT zipcode, area FROM service WHERE zipcode = ‘$zcode'”))){
echo “Record already exists.<br/>”;    
$sql = “INSERT INTO service(zipcode, area) VALUES (‘$zcode’, ‘$ziparea’)”;
$query = mysql_query($sql);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: