i slightly modified a script for a php contact form (http://www.easyphpcontactform.com/). most things seem okay, but once you submit a message, the script prints the 1st and 3rd character of the email address used (so "peanut@percival.com" becomes "p a "). there don't seem to be any error messages, and i can't figure out what would cause it to do that. link is here:
http://www.ojoblanco.com/contact/index.php
and the code:
+++++++++++++++++++++++++++++++++++++++++++++++++
/* Email address where the messages should be delivered */
$to = 'nospam@sogone.com';
/* From email address, in case your server prohibits sending emails from addresses other than those of your
own domain (e.g. email@yourdomain.com). If this is used then all email messages from your contact form will appear
from this address instead of actual sender. */
$from = '';
/* This will be appended to the subject of contact form message */
$subject_prefix = 'Website:';
/* Empty/Invalid fields will be highlighted in this color */
$field_error_color = '#FF0000';
/* Thank you message to be displayed after the form is submitted. Can include HTML tags. Write your message
between <!-- Start message --> and <!-- End message --> */
$thank_you_message = <<<EOD
<!-- Start message -->
<p>Thank You!</p>
<!-- End message -->
EOD;
/* URL to be redirected to after the form is submitted. If this is specified, then the above message will
not be shown and user will be redirected to this page after the form is submitted */
/* Example: $thank_you_url = 'http://www.yourwebsite.com/thank_you.html'; */
$thank_you_url = '';
/*******************************************************************************
* Do not change anything below, unless of course you know very well
* what you are doing :)
*******************************************************************************/
$message = array('Message','message',NULL,NULL);
$email = array('Email','email',NULL,NULL,NULL);
$code = array('Code','captcha_code',NULL,NULL,NULL);
$error_message = '';
if (!isset($_POST['submit'])) {
showForm();
} else { //form submitted
$error = 0;
if(!empty($_POST['message'])) {
$message[2] = clean_var($_POST['message']);
if (function_exists('htmlspecialchars')) $message[2] = htmlspecialchars($message[2], ENT_QUOTES);
}
else {
$error = 1;
$message[3] = 'color:#FF0000;';
}
if(!empty($_POST['email'])) {
$email[2] = clean_var($_POST['email']);
if (!ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email[2])) {
$error = 1;
$email[3] = 'color:#FF0000;';
$email[4] = '<strong><span style="color:#FF0000;">Invalid email</span></strong>';
}
}
else {
$error = 1;
$email[3] = 'color:#FF0000;';
}
if(empty($_POST['captcha_code'])) {
$error = 1;
$code[3] = 'color:#FF0000;';
} else {
include_once "securimage.php";
$securimage = new Securimage();
$valid = $securimage->check($_POST['captcha_code']);
if(!$valid) {
$error = 1;
$code[3] = 'color:#FF0000;';
$code[4] = '<strong><span style="color:#FF0000;">Incorrect code</span></strong>';
}
}
if ($error == 1) {
$error_message = '';
showForm();
} else {
if (function_exists('htmlspecialchars_decode')) $message[2] = htmlspecialchars_decode($message[2], ENT_QUOTES);
$message = "$email[2]\r\n\r\nMessage:\r\n$message[2]\r\n";
if (!$from) $from_value = $email[2];
else $from_value = $from;
$headers = "From: $from_value" . "\r\n" .
"Reply-To: $email[2]";
mail($to, $subject_prefix, $message, $headers);
if (!$thank_you_url) {
echo $GLOBALS['thank_you_message'];
showForm();
}
else {
showForm();
}
}
} //else submitted
function showForm()
{
global $email, $message, $code;
echo $GLOBALS['error_message'];
echo <<<EOD
<form method="post" class="contactForm">
<p><label for="{$message[1]}" style="{$message[3]};">{$message[0]}</label> <textarea name="{$message[1]}">{$message[2]}</textarea></p>
<p><label for="{$email[1]}" style="{$email[3]};">{$email[0]}</label> <input type="text" name="{$email[1]}" value="{$email[2]}" /> {$email[4]}</p>
<p><label for="{$code[1]}" style="{$code[3]};">{$code[0]}</label> <input type="text" name="{$code[1]}" size="10" maxlength="5" /> <img id="captcha" src="securimage_show.php" alt="CAPTCHA Image" /> {$code[4]}</p>
<p style="clear:both;">Enter the text in the image above. Text is not case sensitive. <a href="#" onclick="document.getElementById('captcha').src = 'securimage_show.php?' + Math.random(); return false">Click here if you cannot recognize the code.</a></p>
<p><input class="submit" type="submit" name="submit" value="Submit" /></p>
</form>
EOD;
}
function clean_var($variable) {
$variable = strip_tags(stripslashes(trim(rtrim($variable))));
return $variable;
}
+++++++++++++++++++++++++++++++++++++++++++++++++
any help is most appreciated