How to post/send data to a page using php. [an interesting mission]

Discussion in 'PHP' started by x0x, Oct 1, 2008.

  1. #1
    I need to send information to another page outside my server.

    Let's say the URL is www.site.com/theme.asp?ACTION=EDIT&DETAIL=1013

    Now on my server, what would I have to make to send and post information to that page to a textbox called "username"?

    It would kinda be like a remote controller...


    The submit code on the page:

    <input type=hidden name="FORMACTION" value="SAVEEDITED">
    <input type=hidden name="FORMDETAIL" value="1013">
    <input type="submit" name="submit" value="Save Modifications" alt="Save Modifications">
    </form>
    HTML:

    So basically it let's me set a username on that other page but I'd like to be able to set it by not going to that page, by doing it on my own server.


    Edit: I was going to copy the page's source code and put it on my site, and when I submit info it will post to the URL of the original site. Some simple form trick in the end or something difficult? It's probably pure html...
     
    x0x, Oct 1, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    First you need to collect exact form fields, then make sure the remote site accepts another domain.
    another solution is use CURL to do everything transparently.

    Here is your code purified:

    <form method="post" action="www.site.com/theme.asp?ACTION=EDIT&DETAIL=1013">
    <input type=hidden name="FORMACTION" value="SAVEEDITED">
    <input type=hidden name="FORMDETAIL" value="1013">
    <input type="submit" name="submit" value="Save Modifications" title="Save Modifications">
    </form>
    HTML:
    Btw, use proprty "title" instead of "alt" for non-image items.

    I hope it helps.
     
    Vooler, Oct 1, 2008 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Easy way, look into cURL and pay special attention to the curl_setopt page of the PHP cURL manual.

    Tough way, create HTTP requests manually starting with fsockopen.
     
    joebert, Oct 1, 2008 IP
  4. AimHigher

    AimHigher Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    AimHigher, Oct 1, 2008 IP