View Full Version : problems with php script in the contact form

08-10-2011, 05:09 PM
Hello, I am from the Czech Republic and I am not a coder. I have 2 problems with my php sript. I am using a simple php script from Paul Trani, see below.
Firstly the email adress - when someone inserts an email adress in this form paul@paultrani.com it is OK, but when someone writes an address for example paul.trani@paultrani.cz (this type of adress is very common in our country) the answer is "That is not a valid email address. Please return to the previous page and try again." I think the problem is the dot before the @.

Secondly diacritical marks - Since I am from the Czech Republic we use diacritical marks (for example ,č,ř,,,,,ě) so instead of these letters a get ? or ™ or š to my email.

I really do not know how to fix these problems.

Thank you for any help. Sorry for my English. Lako

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
<title>Email Form</title>


// you can specify which email you want your contact form to be emailed to here

$toemail = "paul@paultrani.com";
$subject = "From EcoStyleStudio.com";

$headers = "MIME-Version: 1.0\n"
."From: \"".$name."\" <".$email.">\n"
."Content-type: text/html; charset=iso-8859-1\n";

$body = "Name: ".$name."<br>\n"
."Email: ".$email."<br>\n"

if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
echo "That is not a valid email address. Please return to the"
." previous page and try again.";

mail($toemail, $subject, $body, $headers);
echo "Thanks for submitting your comments";

08-11-2011, 01:19 AM
try replacing
if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
if (!ereg("^[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))

really not sure abour charset , ut a quick yahoogle suggests iso-8859-2 for your language