SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    keep control when passing form values

    The following code in a file, separate.php, passes values from form to receiving file:

    form -> separate.php file -> vendor's receiving file

    Code:
    <?php
    $url="https://receivingsite.com/receive.jsp?";
    foreach($_POST as $key => $value)
    {
    $url .="$key=" . urlencode($value) . "&";
    }
    header ("Location: $url");
    ?>
    The vendor's regular receiving file (no confirmation page) can't be used because it requires that the form redirect field be included, and that won't work for me because I have two buttons in the form for two separate pages instead of the usual one.

    So I have to send to an alternative receiving file that generates a confirmation page (for my use, unwanted).

    The consequence is that the other code, placed before the code in question, still sends me an email, but no longer opens the next page that I have specified:

    This code:

    Code:
    print "<meta http-equiv=\"refresh\" content=\"0;URL=http://mywebsite.com/next.htm\">";
    is pre-empted by the confirmation page generated by the receiving file.

    What should I substitute for header ("Location: $url"), or other change, so that the page I want opens?
    Last edited by tableman; Apr 26, 2007 at 11:03.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do I need something llike curl, or is there a simple fix?

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still not entirely sure what you mean - mind you I have been up for 19 hours, so here goes...

    Could you not use an include() to send the information to the vendor? it still calls the correct page, but instead of redirecting the browser, it opens there. That way, as soon as it has been sent, you can still redirect the browser to the page you want. unfortunatly, you may see the vendors confirmation page for a second while the redirect takes place...

    The other option is to send the data to *shudder* an invisible iframe using javascript - that way, you cant see the vendors confirmation page, and you can redirect to your conf page at your leasure

    Like I said, not sure if this is what you mean - let me know if I'm talking utter s**te

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, you talk perfect sense. Your suggestions may be what I need.

    99.9% of what I do on my site is html, and I stumble every time I need to cobble together some php.

    Could you give some guidance on how to do the include() option?

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all you would need to do is replace your header() call with

    PHP Code:
    include ($url); 
    then it calls the page you are trying to send the information to, and displays any output as part of the current page - allowing you to continue with your redirect, sending them to your conf page

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent.

    I was trying all the wrong ways to do it, as usual.

    That performs exactly as you had said.

    Pending an alternative that eliminates the confirmation page, I can live with the brief confirmation page flash on the way to the right page.

    You indicate that the invisible iframe and javascript is not desirable, probably beyond my capacity as well.

    What about passing the $url variable to the file() function?

    Could that be a way to do this?

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hm... yeah, I guess you could! Didn't think of that - I very rarely use the file() function, never needed too, but as far as I know that should work - give it a try anyway

    To make sure it works, I would get the php to print out the contents of the page, just while testing - I cant see any problems, but just be sure it works

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been reading further on the file() function but I don't see how it would solve this.

    Maybe someone who knows more than me can see how.
    Last edited by tableman; Apr 26, 2007 at 16:27.

  9. #9
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all you need to do is:
    PHP Code:
    $array file($url); #Reads File To Array 
    Then, for testing purposes, to print out the result, use this code:
    PHP Code:
    $x '0';
    while (
    $x count($array)){
    print 
    $array[$x] . "\n";
    $x++;

    All that does is loop round each element in the array, and print it out - just use that to check that the data is being sent to the vendor correctly - then remove it once you are satisfied its working correctly.

    Hope this helps

  10. #10
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow.

    That did it!

    The values go into the file, the next page opens, and no confirmation page shows.

    Thank you so much!

    Solved

  11. #11
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Location
    Swindon, UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no problem glad i could help


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
  •