Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-22-2007, 07:53 AM   #1
digitalecartoon
Senior Member
 
Join Date: Aug 2005
Posts: 289
Default Name regex doesn't work?

This is my php mail script for my Flash form. I'm using utf8_decode because I noticed that Flash sends it's values utf encoded. So RenÚ would be send something like Ren%8. Using utf8 encoded fixed that and RenÚ kept being send as RenÚ.

But now I notice that apostrophe characters are regarded as false by my name regex? I've tested the regex online and a name as John O'Connor was accepted. All I did was add an escape character because the preg_match line was surrounded by apostrophes so I thought that might give a conflict.

Can someone tell me what I, Flash or PHP are doing wrong?

Code:
<?php

/* Email settings */
$to = "[email protected]";
$subject = "Een mailtje via de website";
$naam = utf8_decode($_POST["naam"]);
$email = utf8_decode($_POST["email"]);
$bericht = utf8_decode($_POST["bericht"]);

/* Check for name, including accented characters and apostrophe */
if (!preg_match('~^[a-z└- ][\'a-z└-  \-]*$~i', $naam)) {
$naam = "error";
echo "&naam=error&";
} else {
echo "&naam=correct&";
}

/* Check email address */
if (!preg_match('~^[a-z0-9][a-z0-9_.\-]*@([a-z0-9]+\.)*[a-z0-9][a-z0-9\-]+\.([a-z]{2,6})$~i', $email)) {
$email = "error";
echo "&email=error&";
} else {
echo "&email=correct&";
}

/* Strip tags message */
$bericht = strip_tags($bericht);
if (!$bericht) {
$email = "error";
echo "&bericht=error&";
} else {
echo "&bericht=correct&";
}

/* Send mail if correct */
if ($naam != "error" && $email != "error" && $bericht != "error") {

$message = "Naam:\r\n".$naam."\r\n\r\n";
$message .= "Emailadres:\r\n".$email."\r\n\r\n";
$message .= "Bericht:\r\n".stripslashes($bericht)."\r\n";

$headers = "MIME-Version: 1.0\r\n";  
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: ".mb_encode_mimeheader($naam, "iso-8859-1", "Q")." <".$email.">\r\n";  

mail($to, $subject, $message, $headers);

}
?>
digitalecartoon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Paths in external swf doesn't work Kiri11 ActionScript 1.0 (and below) 7 12-18-2009 03:55 AM
On the verge of tears: why doesn't this preloader work (Cyan, Billy, Fafie, anybody?) Ericinho ActionScript 1.0 (and below) 5 07-25-2003 06:37 AM
unescaping html oddballs from xml sent from flash to PHP Philip Toews Server-Side Scripting 30 06-01-2003 02:27 AM
Resizing Work Area? binar ActionScript 1.0 (and below) 0 07-10-2002 04:13 PM


All times are GMT. The time now is 08:26 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.