Here's my code:
<?php
// create short variable names
$state=$_POST['state'];
if (!$state)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
if (!get_magic_quotes_gpc())
{
$state = addslashes($state);
}
$con = mysql_connect("localhost","qfs","abc123","applicants");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$query = "insert into applicants values
('".$state."')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' application inserted into database.';
mysql_close($con);
?>