Jump to content

Archived

This topic is now archived and is closed to further replies.

avo

check for symbol in text field before $_POST

Recommended Posts

HI All

Is it possible for you to let me know how to check for a symbol in a text field before a post
i thought i should use a wildcard and tryed

[code]<?

if ($_POST ['email'] !=@% ) {
$no_symbol = "bad;
} else {

$no_symbol = "good;
}

?>[/code]

but i was wrong only came up with errors

if someone can point me in the direction of the variable that i need to use i will it will be most appriciated..

Thank in advance.

Share this post


Link to post
Share on other sites
[!--quoteo(post=369046:date=Apr 26 2006, 03:18 PM:name=avo)--][div class=\'quotetop\']QUOTE(avo @ Apr 26 2006, 03:18 PM) [snapback]369046[/snapback][/div][div class=\'quotemain\'][!--quotec--]
HI All

Is it possible for you to let me know how to check for a symbol in a text field before a post
i thought i should use a wildcard and tryed

[code]<?

if ($_POST ['email'] !=@% ) {
$no_symbol = "bad;
} else {

$no_symbol = "good;
}

?>[/code]

but i was wrong only came up with errors

if someone can point me in the direction of the variable that i need to use i will it will be most appriciated..

Thank in advance.
[/quote]

You could do it using regular expressions and look for the @ character. I'm not good at them but I am sure someone else could enlighten both of us how to look for the @ symbol.

Share this post


Link to post
Share on other sites
[code]if (strpos($_POST['email'], '@') !== false) {
    # has '@' symbol
}
else {
      # invalid email address
}[/code]

Share this post


Link to post
Share on other sites
Thankyou

Much appriciated.

Share this post


Link to post
Share on other sites
HI

Just tryed the code
but it assigns the variable to bad regardless if the @ symbols is pressent or not

[code]//check if email text filed as @ symbol pressent
if (strpos($_POST['email'], '@') !== false) {
$frm_check_email  = "good";
}
else {
$frm_check_email = "bad";
$frm_check = "bad";
}[/code]

hope you can help again

thanks.

Share this post


Link to post
Share on other sites
try echoing the $_POST['email'] as a check. I get 'good' if there's an '@'.

Share this post


Link to post
Share on other sites
Thanks Barand for you help .

I was getting confused i left it for last night came back this morning to it and relised i was trying to capture a text filed that did not exsist i was looking for [code]$_POST ['email'] instead of $_POST ['memail'] [/code] silly misstake

Works just as i wanted i will now remember strpos

THANKS .

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.