I'm trying now to check the POST array for and email address var (checking that the $value to the key $_POST[EMAIL] is actually an email addy and not random text) probably using a very primative method but it should work well enough. If people dont want to submit email then they wont or they will likely enter "yomamma@yomamma.com" or something of the like if they feel they need to expend the effort - its not a required field here...
anyhow - the script checks for the string length to see if anything was sent for this value (this works)
then checks for the presence of "@" AND "." (this is where things get weird - if there is neither "@" or "." then we go to the else{} clause, thats good, if there is only "." again to the else{} clause, still good -- BUT when there is only "@" it validates, bad news - why? anybody know?)
I decided that if I went ahead to check the string position value (should return numerical value of position occupied by search character in charachters of string - yes?) of the "@" which should be first (Ex: yomamma"@"yomamma.com) to the string position of the "." which should be second in order (Ex: yomamma@yomamma"."com) that even if the authentication got through the check for both "@" and "." with only "@" present that it should cause failure here and go to the else{} clause - which would be fine
heres where this gets hairy...
the var holding the value for string position of "@" either holds nothing or when type cast int becomes zero every time (for both "@" and ".") - the is no error thrown and a jump straight to the else{} clause every time
code is as follows...
////////////THIS WORKS FINE/////////////
if(strlen($_POST[EMAIL])>0){
//if(eregi("@", $_POST[EMAIL]) && eregi(".", $_POST[EMAIL])){
//$number = strpos("@", $_POST[EMAIL]);
//if($num>1 && strpos(".", $_POST[EMAIL])>$num){
echo'email';
//}else{
// echo'not email';
//}
//}else{
// echo'not email';
//}
}
///THIS WORKS BUT ALLOWS ONLY "@" TO PASS ALSO///////////////////
if(strlen($_POST[EMAIL])>0){
if(eregi("@", $_POST[EMAIL]) && eregi(".", $_POST[EMAIL])){
//$number = strpos("@", $_POST[EMAIL]);
//if($num>1 && strpos(".", $_POST[EMAIL])>$num){
echo'email';
//}else{
// echo'not email';
//}
}else{
echo'not email';
}
}
//THIS PRINTS 'NOT EMAIL' ALWAYS'//////
if(strlen($_POST[EMAIL])>0){
if(eregi("@", $_POST[EMAIL]) && eregi(".", $_POST[EMAIL])){
$num = strpos("@", $_POST[EMAIL]);
if($num>1 && strpos(".", $_POST[EMAIL])>$num){
echo'email';
}else{
echo'not email';
}
}else{
echo'not email';
}
}
//THIS PRINTS NOTHING - NOT EVEN else{} CLAUSE///////////
if(strlen($_POST[EMAIL])>0){
if(eregi("@", $_POST[EMAIL]) && eregi(".", $_POST[EMAIL])){
$num = strpos("@", $_POST[EMAIL]);
//if($num>1 && strpos(".", $_POST[EMAIL])>$num){
echo $num;
//}else{
// echo'not email';
//}
}else{
echo'not email';
}
}
///THIS IS THE ONLY WAY TO EVEN GET ZERO//////////
if(strlen($_POST[EMAIL])>0){
if(eregi("@", $_POST[EMAIL]) && eregi(".", $_POST[EMAIL])){
$num = (int)strpos("@", $_POST[EMAIL]);
//if($num>1 && strpos(".", $_POST[EMAIL])>$num){
echo $num;
//}else{
// echo'not email';
//}
}else{
echo'not email';
}
}
this is all with no errors thrown (weird???) - anybody have any ideas?? feel free to test this code I'd love to know if anybody else gets the same results or if it works - is there an .ini setting that needs tweaking?? I'm confused because strpos("search_char", $string) should feed back a number if string is present right?