How to send POST information without user input

Discussion in 'PHP' started by TaMeD, Jan 1, 2009.

  1. #1
    Ok, well basically I have a page with some variables which i want to send to a different page without using $_GET.. How the heck do i do this? ;)

    Thanks in advance.
     
    TaMeD, Jan 1, 2009 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    WITHOUT user input? Research AJAX (which is JavaScript).
     
    zerxer, Jan 1, 2009 IP
  3. TaMeD

    TaMeD Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I know ajax, but i don't want to use it. I would like a solution using php hopefully.:cool:
     
    TaMeD, Jan 1, 2009 IP
  4. lyal

    lyal Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Okay - I'm making some assumptions in answering your post. I'm guessing you mean you don't want a form post back.. you want an automated AJAX callback.

    To accomplish this, you could code it in pure javascript, or use a framework. In the example below, I use jquery to accomplish it. One caveat you might not be aware of: Post callbacks can only be used on the same domain as the server sending the base page, so this won't work for submitting forms to other websites without the user's permission.

    <script>
    $(document).ready(function() {
    $.post("test.php", { var1: 'welcome', var2: 'home'});
    });
    </script>
     
    lyal, Jan 1, 2009 IP
  5. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #5
    PHP is all server-side. There's nothing client-side about it. The AJAX portion is the client-side code which loads another file which can execute the PHP that's inside the file it calls.

    So basically, these two things are similar:
    User input (clicking a link, submitting a form, etc) -> Loads a page -> PHP is executed in the page loaded -> Output is sent to user

    AJAX through JavaScript -> Loads a page in the background -> PHP is executed on the page loaded -> Output is returned to the AJAX caller


    Either way, you'll still have the PHP executed. I recommend using jQuery as the previous poster mentioned. Awesome framework. http://www.jquery.com/
     
    zerxer, Jan 1, 2009 IP
  6. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe he's looking more a server-side script to send POST data to another script?

    If so, it would pay you to look into 'curl'...
     
    TwistMyArm, Jan 2, 2009 IP
  7. TaMeD

    TaMeD Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I think that may be what im looking for. I'll take a look into it when I can.

    Thank you! :)
     
    TaMeD, Jan 2, 2009 IP
  8. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #8
    Use sessions.
     
    Kaizoku, Jan 2, 2009 IP
  9. Scoty

    Scoty Active Member

    Messages:
    620
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #9
    This is also how I got around this problem
     
    Scoty, Jan 2, 2009 IP
  10. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    <input type="hidden" value="<?php echo previuos data; ?>" />
     
    AnonymousUser, Jan 2, 2009 IP
  11. Yesideez

    Yesideez Peon

    Messages:
    196
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11
    How about cURL?
     
    Yesideez, Jan 2, 2009 IP
  12. Scoty

    Scoty Active Member

    Messages:
    620
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #12
    I'd do that if needing to transport variables across multiple form pages but I think he was looking for the solution sessions bring, so it doesn't require user interaction (that's how I picked it up anyway)
     
    Scoty, Jan 3, 2009 IP