Hello all,
The following captcha script works fine, but only with $name, $email and $message.
As you can see I have added $bname, $add, $postcode etc.
My Question is, how/where do I amend the script to include those new variables in the email that has sent?
I have played about with the line
mail("paul.white1978@hotmail.com","Email Subject ","Name: $name\n Email: $email\n\n Message:$message","From: $email");
, but have had no joy.
Here is the full script:
<?php
session_start();
?>
<?php
if (isset($_POST['submit'])) {
if (isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']) {
// Grab the form vars
$name = (isset($_POST['name'])) ? $_POST['name'] : '' ;
$email = (isset($_POST['email'])) ? $_POST['email'] : '' ;
$org = (isset($_POST['org'])) ? $_POST['org'] : '' ;
$bname = (isset($_POST['bname'])) ? $_POST['bname'] : '' ;
$add1 = (isset($_POST['add1'])) ? $_POST['add1'] : '' ;
$add2 = (isset($_POST['add2'])) ? $_POST['add2'] : '' ;
$county = (isset($_POST['county'])) ? $_POST['county'] : '' ;
$pcode = (isset($_POST['pcode'])) ? $_POST['pcode'] : '' ;
$message = (isset($_POST['message'])) ? $_POST['message'] : '' ;
// Check for email injection
if (has_emailheaders($email)) {
die("Possible email injection occuring");
}
mail("paul.white1978@hotmail.com","Email Subject ","Name: $name\n Email: $email\n\n Message:$message","From: $email");
$message = 'Your message has been recieved';
} else {
$message = 'The word verification was not correct. Please press back and resubmit.';
}
} else {
$message = 'Please use the contact form for communication';
}
function has_emailheaders($text) {
return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text, $org);
}
?>
</head>
<body>
<div style="text-align:center">
<h1>Your message has been sent</h1>
<h2><?php echo $message; ?></h2>
</div>
</body></html>