'.mysql_error());
mysql_select_db ("$db_name") or die ('Error Selecting DB: '.mysql_error());
$surname = mysql_real_escape_string($_POST['surname']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$phone1 = mysql_real_escape_string($_POST['phone1']);
$phone2 = mysql_real_escape_string($_POST['phone2']);
$location = mysql_real_escape_string($_POST['location']);
$qualifications = mysql_real_escape_string($_POST['qualifications']);
$expertise = mysql_real_escape_string($_POST['expertise']);
$assistance = mysql_real_escape_string($_POST['assistance']);
$languages = mysql_real_escape_string($_POST['languages']);
$e_mail = mysql_real_escape_string($_POST['e_mail']);
$consent = mysql_real_escape_string($_POST['consent']);
$published = mysql_real_escape_string($_POST['published']);
$comments = mysql_real_escape_string($_POST['comments']);
$other_info = mysql_real_escape_string($_POST['other_info']);
$errorstring = ""; // default value of errorstring
function makeSafe($value)
{
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
$value = mysql_real_escape_string($value);
return $value;
}
if(isset($_POST['submit'])) {
// Validate all the code inputs
// Captcha Validation
require_once('recaptchalib.php');
$privatekey = "etcetcetc";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
$errorstring = $errorstring. "Invalid CAPTCHA, please try again";
} else {
if ($surname =="")
$errorstring = $errorstring. "Surname ";
if ($phone1 =="")
$errorstring = $errorstring. "phone1 ";
if ($phone2 =="")
$errorstring = $errorstring. "phone2 ";
if ($location =="")
$errorstring = $errorstring. "location ";
if ($qualifications =="")
$errorstring = $errorstring. "qualifications ";
if ($assistance =="")
$errorstring = $errorstring. "assistance ";
if ($languages =="")
$errorstring = $errorstring. "languages ";
if ($e_mail =="")
$errorstring = $errorstring. "e_mail ";
if ($consent =="")
$errorstring = $errorstring. "consent ";
if ($published =="")
$errorstring = $errorstring. "published ";
if ($comments =="")
$errorstring = $errorstring. "comments ";
if ($other_info =="")
$errorstring = $errorstring. "other info ";
// does the errorstring = "nothing"?
}
// Figure out which error message to show i.e. field validation or CAPTCHA
if ($errorstring !="")
if (strstr($errorstring,"CAPTCHA")) echo $errorstring;
else echo "You have not put anything in the following fields:
$errorstring";
//echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\"";
//die ("Please try again, ensuring that you fill out all the fields!");
else
{
//echo "Your data has been saved";
$insert_query = "INSERT INTO HelperFormData (surname, firstname, phone1, phone2, location, qualifications, expertise, assistance, languages, e_mail, consent, published, comments, other_info) VALUES ('$surname', '$firstname', '$phone1','$phone2', '$location', '$qualifications', '$expertise', '$assistance', '$languages', '$e_mail', '$consent', '$published', '$comments', '$other_info')";
$insert_action = mysql_query($insert_query) or die ('Error During Insert : '.mysql_error().'
Error occured running the following code : '.$insert_query);
$id = mysql_insert_id();
echo "Thank you, Your details have been submitted.";
//include "resultcard.php";
// Output what the form looks like
// End of how the form looks
}
}
if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring)))
{
?>