<?php
if (isset($_POST['first_name'])) {
// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password');
if(!is_resource($link)) {
echo "Failed to connect to the server\n";
// ... log the error properly
} else {
// Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON.
if(get_magic_quotes_gpc()) {
$last_name = stripslashes($_POST['last_name']);
} else {
$last_name = $_POST['last_name'];
}
// Make a safe query
$query = sprintf("SELECT * FROM `customers` WHERE `last_name` = '%s'",
mysql_real_escape_string($last_name, $link);
mysql_query($query, $link);
if (mysql_affected_rows($link) > 0) {
echo "Product inserted\n";
}
}
} else {
echo "Fill the form properly\n";
}
?>
plzzz check this code out and suggest me the modifications!!