Results 1 to 6 of 6

Thread: php redirect with dynamic url

  1. #1
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php redirect with dynamic url

    hi,
    i have a form on my site and once filled out, the user is redirected to a page outside my site. i now would like to have them redirected to another page in my site and then redirected again outside the site to that same page. the info entered in the form creates the url that leads outside the site...is it possible to keep this with the addition of the internal page?

    does this make sense?
    thx

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could call the variables from the original form in the page that the user gets redirected to (within your site). By using $_POST, $_GET, or $_REQUEST you could get these values and then forward them to the external page.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    On the receiving page, for example,
    PHP Code:
    <?php
    header
    ('Location: http://my.com/'.$_POST['page'].'.php');
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your responses. sorry if i was unclear, i am fairly new to all of this. so if i am understanding you correctly....

    this is the code i have that passes the variables to the url:

    $offerCode = "1234";
    $checkCode = "cc";
    $shortKey = "cccccc";
    $longKey = "123456";
    $pin = $_REQUEST['email'];

    $eCoupon = new Coupon();
    $coupon_url = $eCoupon->generateURL($pin, $offerCode, $shortKey, $longKey, $checkCode);

    header("Location: ".$coupon_url);
    return;

    so when the user hits submit...the form uses the post method to call the file with the above code.

    so i would use the above code by dj233 to obtain the parameters? would it also be possible to change the code i provided to redirect to the new internal page and then when it redirects pass them along to the external page? and when you say 'page' above...are you referring to the new internal? again, sorry i am new.

    thanks again for all of your help...

  5. #5
    Join Date
    May 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    this seems to be working except that the email variable is not getting passed along. so for example, i have:

    -form.php (what the html form gets posted to):

    header("Location: /internal.php");

    -internal.php:

    $var = "123";
    $var2 = "456";
    $email = $_REQUEST['email']; // in html form

    $eurl = new Url();
    $new_url = $eurl->generateURL($email, $var, $var2);
    header("Location: ".$new_url);
    return;

    generateURL is in a separate file with the code to build that.

    it redirects fine, but it errors at the external page showing that it is missing a parameter ( so far as i can tell it is only missing the email).

    can anyone help? thanks.

  6. #6
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    You need to put $_REQUEST['email'] into a hidden input on form.php, use javascript to automatically submit form.php to internal.php carrying $_REQUEST['email'] with it.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

Bookmarks

Posting Permissions

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