SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Hiding from the world
    0 Post(s)
    0 Thread(s)

    header redirect with multiple get variables not working

    i am setting up our enewsletter system so that when we send it it automatically searches through the text and changes the link to a different one with an idenifier and logs it in a db table. I can then point all links to a page which records that the link has been used and redirects them to the original link from the table.

    I've got the header redirect working fine but i need to beable to change the url. I tried preg_replace to just add in some text before the address and just make the original address a &_get variable but this falls down if the link contains a '&' eg
    the rel2 is seen as a separate variable and not part of link, which i guess makes sense as it hits the & and thinks its different.

    so now i'm thinking of changing all of the address for another using something like this
    $data1 = "This is one website <a href=\"\">blah</a> oh but there is also this one <a href=\"\">blah</a>";
    preg_match('/\="(.*?)\">/', $data1, $matches);
    // here we would insert the url into the database and generate a random number for the url to replace it with.
    $domain = $matches[1];
    //just echo out the link for testing
    echo $domain;
    Only problem is it only finds the first url in the string. How do i make it change for everyone it finds.
    any help is much appreciated. thanks
    If i am a product of your imagination you should try harder!

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Kathmandu, Nepal
    0 Post(s)
    0 Thread(s)
    The preg_match_all() function is the right function to use in such case.
    Mistakes are proof that you are trying.....
    PSD to HTML - | Personal Blog | ZCE - PHP 5


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts