Forum Moderators: coopster

Message Too Old, No Replies

allowing letters, numbers in form only

         

jake66

5:56 am on May 24, 2006 (gmt 0)

10+ Year Member



in my contact form i have people consistently typing in foreign characters (like chinese for example) that end up turning into a bunch of question marks when i open the mail because i don't have that character set installed.

my form:
$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);
[prepares it]

<?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15, tep_sanitize_string($_POST['enquiry']), '', false);?>
[builds the textarea that people will be typing into]

i would like to allow only:
letters, punctuation, spaces, _, $ and accents

i've done several web searches and on php.net and i cannot figure it out.

i would like the error to be posted on the current page (not redirected to another page) that informs the visitor what the problem was... so they don't have to retype everything.

any suggestions?

ahmedtheking

8:37 am on May 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this: preg_match()

if (preg_match("/[a-zA-Z0-9_\-]+/",$data)) {
// all good
} else {
// error
}