Hello,

I am using a wysiwig editor (Spaw)
That allows the use of checking the refferer for the dynamicly changing location of the image path to upload to.

The reffer is:
http://www.domain.net/traveltalk.php?mode=post&forum_id=1

or

http://www.domain.net/traveltalk.php?mode=reply&forum_id=1&main_id=15

Were forum_id could be any number and main_id could be any number.

How do I program an if statement that covers this?

if ($reffer == "http://www.domain.net/traveltalk.php?mode=post&forum_id=[any number]" or $reffer == "http://www.domain.net/traveltalk.php?mode=reply&forum_id=[any number]&main_id=[any number]"){
$imgpath = "path_to_images/";
}else{
$imgpath = "some_other_path/";
}

Thank You,
Chris Wheat

    you may want to look into regular expressions - a function that will be of interest is f.ex. [man]eregi/man.

    rock on

      Thank you this points me in the correct direction, however where do I find out what all the expression mean?

      ie in the examples the use:
      (".[a-zA-Z0-9..-]+@[a-z0-9]+\.[a-z]+

      I prosume [0-9] means any number
      and [a-z] means any alpha
      but where do I find a detailed list of all the expressions?

      Thanks
      Chris

        If you used the PCRE functions instead (for reasons mentioned on the [man]regex[/man] page (which also links to the relevant syntax documentation for ereg())), then the PHP manual itself covers the syntax. (The POSIX syntax used by ereg() is similar, but smaller).

          Thank you guys!!!

          Here is what I came up with:

          $string = "http://www.domain.net/traveltalk.php?mode=reply&forum_id=1&main_id=99";
          if (preg_match("/^http:\/\/www.domain.net\/traveltalk.php\?mode=reply&forum_id=[0-9]*&main_id=[0-9]*$/", "$string")) {
          print "whahoo";
          }else{
            print "boo";
          }
          
            Write a Reply...