Computing.Net > Forums > Programming > PHP find characters in field

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP find characters in field

Reply to Message Icon

Name: ian_ok
Date: August 30, 2005 at 08:44:01 Pacific
OS: win xp 98 & 2k
CPU/Ram: p3 512
Comment:

I'm trying to find certain characters in a field and display and error or emove that sign now I want to allow:
the @ sign but don't want to allow % , ;

If I use this:
elseif (preg_match('/[[:punct:]]/', $_POST['from'])){
echo "Punct error";
}
It replies error for any @ entered but I want the @ symbol to be allowed.

Also if a field contains say the word bcc I want a error to say the word bcc is not allowed or just to remove it.

Is this possible?

Ian

Venta Sanlucar Sales



Sponsored Link
Ads by Google

Response Number 1
Name: ian_ok
Date: August 31, 2005 at 02:47:34 Pacific
Reply:

I've managed to do the code which is:

function validate_from_field($s) {
$forbidden = array('%', ',', ';', 'bcc');
foreach ($forbidden as $f)
if (strpos($s, $f) !== false) return false;
return true;
}

---
if (!validate_from_field($_POST['from'])) {
echo "<h4>Sorry you have entered an invalid email address, please check and try again</h4>";
echo "Click here to return";
echo "<h4></h4>";
echo "<h4>If you are having problems with this form please email email@domain.com </h4>";


Venta Sanlucar Sales


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: PHP find characters in field

count # of characters in file + EOF www.computing.net/answers/programming/count-of-characters-in-file-eof/4457.html

Special characters in batch www.computing.net/answers/programming/special-characters-in-batch/19558.html

Null Character in C? (NOT '\0') www.computing.net/answers/programming/null-character-in-c-not-0/3201.html