Hi All, :rolleyes:

I wrote a code and it doesnt do nething :glare:

function submission_junky($uemail) {
global $prefix, $db, $module_name, $adminmail;

if( preg_match("hotmail", $uemail)); {
	$hotmail = (".hotmail.");
} else {
	preg_match("yahoo", $uemail)); {
	$yahoo = (".yahoo.");
} else {
	preg_match("aol", $uemail)); {
	$aol = (".aol.");
	}
}

if(preg_match == 1); {
	$junkmail = (".Youareusinga." $hotmail, $yahoo, $aol ".emailaddress.");
} else {
	preg_match == 0;
	$junkmail = (".thankyou.")
	}
}

$uemail = User Email = this is a field in a form
$junkmail = Email address provider in use

What i want the code to hopefully do...

I want it too look for Homail, Yahoo or AOL in $uemail

if there is one of those email providers there, the i want it to say the one it has picked up, then on the next page it will say something like :

You are using a <b>Hotmail</b> email Address

I would then make a link where the user can click it and too see where the emails from my site goes, either in the inbox on the junk mail in there emails.

Hope someone can help 🙂

Thanks in Adv

    Read up on Regular Expressions.

    I'm gonna take a guess and say that you probably want a word boundary:

    if( preg_match("/\\bhotmail\\b/i", $uemail)); {
        $hotmail = (".hotmail.");
    } else {
        preg_match("/\\byahoo\\b/i", $uemail)); {
        $yahoo = (".yahoo.");
    } else {
        preg_match("/\\baol\\b/i", $uemail)); {
        $aol = (".aol.");
        }
    }

    ~Brett

    EDIT
    FREAKIN PHP TAGS!!!! BAH!!!

      Read up also on the if statement. Get yourself a grasp on the basics of the language. At present your code is pretty much munted (which is why it no doubt spews parse errors); I suspect you're much more familiar with some other language and keep trying to use its syntax (though I don't recognise the language).

        Hi again

        i cant seem to get this working

        if(preg_match == 1); { 
            $junkmail = (".Youareusinga." $hotmail, $yahoo, $aol ".emailaddress."); 
        } else { 
            preg_match == 0; 
            $junkmail = (".thankyou.") 
            } 
        }
        

        i am just getting parse errors... and the code i was given i was getting else errors... more parse

        so i had to put it like this

        if( preg_match("/\bhotmail\b/i", $uemail)); { 
            $hotmail = (".hotmail."); 
        	}
        
        
        if( preg_match("/\byahoo\b/i", $uemail)); { 
            $yahoo = (".yahoo."); 
        	}
        
        if( preg_match("/\baol\b/i", $uemail)); { 
            $aol = (".aol."); 
            } 
        

        everytime i think of something extra for my site... something always go's wrong!! :glare:

        Weed: i mainly work with flash action scripting, html and vb, anyways i am a designer not that much of a coder... but i want to learn! :bemused:

          Weedpacket said:

          Read up also on the if statement. Get yourself a grasp on the basics of the language.

          You said:

          ...i want to learn!

          If so, then you would be following WP's advice, and you'd realize that you have several semicolons in your code that don't belong there.

          Also, if you used code like this:

          if (stristr($uemail, 'hotmail')) {  
          $hotmail = (".hotmail.");
          }

          then you could put off learning regular expressions (which are overkill in a simple situation like this, anyway) until you know PHP a little better.

          String Functions
          Control Structures

            Thanks for ya helps guys, just need 2 more things :rolleyes:

            can ya check this for me... see if its all gud

            function submission_junky($uemail) {
            
            //Find The Email Text
            
            if  (stristr($uemail, 'hotmail')) {   
            $hotmail = (".hotmail.");
            } elseif (stristr($uemail, 'yahoo')) {
            $yahoo = (".yahoo.");
            } elseif (stristr($uemail, 'aol')) { $aol = (".aol.");
            } //Display the Information //No Information Found if (stristr == 0) { $junkmail = ("'. _SFPOSTED.'"); } elseif //Information Found (stristr == 1) { $junkmail = ("$hotmail, $yahoo, $aol, '. _SFPOSTED.'"); } }

            So the last if...

            If there was none of the varibles then it will just show SFPOSTED

            But if there is it will only show the one found and SFPOSTED

            😃 😃

            Finally... i am a little confused with this part :queasy:

            "<input type='hidden' name='op' value='submission_junky, submission_send'>"
            

            Is this correct... i would need the submit button to go in the junky function first before going into the send function

            and then hopefully that will be it 😃

            thankyou

              I don't really know what purpose the hidden form field will serve. It looks to me like you can do without it. In your form processing script, just check if "$_POST['submit']" is set. If it is, then run the email string through your function.

              In the function, first set "$hotmail", "$yahoo", and "$aol" to "". Then have your first three "if" blocks just as they are. After that, just return the "$hotmail, $yahoo, $aol, '. _SFPOSTED.'" string (no "if" needed).

              BTW, "stristr" is a function name, not a variable, so "if (stristr == 0)" isn't a valid construct.

                Have i done it oks this time ?

                $return = ('$hotmail', '$yahoo', '$aol', '');
                if  (stristr($uemail, 'hotmail')) {   
                $hotmail = (".hotmail.");
                } elseif (stristr($uemail, 'yahoo')) {
                $yahoo = (".yahoo.");
                } elseif (stristr($uemail, 'aol')) { $aol = (".aol.");
                } $return .= ('$hotmail', '$yahoo', '$aol', ''); return $return; else return false; { $junkmail = ("'. _SFPOSTED.'"); } else return true; { $junkmail = ("$hotmail, $yahoo, $aol, '. _SFPOSTED.'"); }

                I readed this page: http://www.php.net/manual/en/ref.strings.php
                the str one

                to be honest i didnt know what i was looking for!

                i am just getting confused with what you mentioned the last post...

                In the function, first set "$hotmail", "$yahoo", and "$aol" to "". Then have your first three "if" blocks just as they are. After that, just return the "$hotmail, $yahoo, $aol, '. _SFPOSTED.'" string

                Thanks 🙂

                  He means:

                  <?php
                  // Set hotmail, yahoo, and aol to empty strings:
                  $hotmail = "";
                  $yahoo = "";
                  $aol = "";
                  
                  // Do your IF thing:
                  if  (stristr($uemail, 'hotmail')) {   
                  $hotmail = (".hotmail.");
                  } elseif (stristr($uemail, 'yahoo')) {
                  $yahoo = (".yahoo.");
                  } elseif (stristr($uemail, 'aol')) { $aol = (".aol.");
                  } // Concatenate the string to return $string = $hotmail.', '.$yahoo.', '.$aol.', "._SFPOSTED."'; // Return the string return $string; ?>

                  ~Brett

                    Yep, that's what I mean. But don't forget that the code Brett posted is the internal code for your function "submission_junky($uemail)".

                      Write a Reply...