HI,
Below is fully functional, non-functional code :^): In other words, it
works, but it doesn't do anything and darned if I can see why. None of
the 3 $email assignments result in any output. I just kept two
commented out so I could easily switch addresses for testing, thus the
"#"s. It does not kick out any errors and syntax checks valid with
tswebeditor (freebie).
I've sprinkled some echoes here and there to try to see what's running
but no help. I've indicated the ones that DO echo properly for me with
<-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be getting
run, indicating something pretty obvious I'm sure, just not obvious to
me!
Any Help?
Twayne
---------------------
<?php
$email="mine@do main.com";
#$email="a@b.c" ;
#$email=".mine. @.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($ email){
$output = "Might be valid.";
$email = trim($email);
If ((strlen($email )<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($ email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halve s[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
?>
--------- end ------------------
Below is fully functional, non-functional code :^): In other words, it
works, but it doesn't do anything and darned if I can see why. None of
the 3 $email assignments result in any output. I just kept two
commented out so I could easily switch addresses for testing, thus the
"#"s. It does not kick out any errors and syntax checks valid with
tswebeditor (freebie).
I've sprinkled some echoes here and there to try to see what's running
but no help. I've indicated the ones that DO echo properly for me with
<-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be getting
run, indicating something pretty obvious I'm sure, just not obvious to
me!
Any Help?
Twayne
---------------------
<?php
$email="mine@do main.com";
#$email="a@b.c" ;
#$email=".mine. @.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($ email){
$output = "Might be valid.";
$email = trim($email);
If ((strlen($email )<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($ email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halve s[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
?>
--------- end ------------------
Comment