Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Question Unanswered: Pass form data from one server to another server

    I'm new in this forum and new to PHP but my research shows that PHP can do what I'm trying to do. I'm just not quite sure how to implement it. I also have done my search of the PHP forum and I didn't find anything similar to my problem. So here it goes...

    What I want is to pass data collected in domain1.com/form.html to otherdomain.com/scripts/dbscript.php. The otherdomain.com has the script to insert data collected from domain1.com's form into otherdomain.com's database. I have looked at Include(), Require() and Header.

    Sysadmin at otherdomain.com also told me to use HTTP GET variables but wouldn't POST be better?

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    should be able to work with either POST or GET Method of Form variables. You can put this at the top of your script to check for either POST or GET Variables. You will want to do some data validation on the receiving end to prevent malicious input.

    PHP Code:
    $PARAMS = ( count$HTTP_POST_VARS ) )
           ? 
    $HTTP_POST_VARS  $HTTP_GET_VARS

    '
    ~

    Bill

  3. #3
    Join Date
    Oct 2004
    Posts
    3
    Thanks for the response. This is what I have right now...

    A form which submits to a PHP file. Both are in domain1.com. Domain1.com's PHP file grabs the form variables and then using Include() it relays the info to the otherdomain.com. Is this correct?

    <?php
    $PARAMS = ( count( $HTTP_POST_VARS ) )
    ? $HTTP_POST_VARS : $HTTP_GET_VARS;

    include 'http://www.otherdomain.comt/scripts/dbscript.php?var1=var1&var2=var2';
    ?>

    Is that all I need to pass variable data to otherdomain.com's PHP script? I've tried and so far no data in the database

  4. #4
    Join Date
    Feb 2004
    Posts
    533
    I that should work except somewhere between defining the $PARAMS Array and calling the target script you will need to define the Array variables to Local variables. Havn't tested this just a quick example.

    PHP Code:
    //you could use a loop or just assign the known variables
    $var1 $PARAMS['firstname'];
    $var2 $PARAMS['lastname'];
    $var3 $PARAMS['address'];

    //create your get string
    $getstring "Var1=" $var1 "&Var2=" $var2 "&Var3=" $var3;
    include 
    'http://www.otherdomain.comt/scripts/dbscript.php?' $getstring;

    //You could use a function in the include file, define your variable and pass them to the function. 
    ~

    Bill

  5. #5
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Maybe I've over simplified this, but it seems like he is just trying to post data to a remote server - i.e. this can be done by just setting the action element on the form tag? i.e. (change the method= to the required GET/POST)

    Code:
    <form action="http://myserver.com/dbscript.php" method="GET">
    Bill is right, you'll need to do something to stop malicous input (however unlikely you think it will be). Though, as it sounds like you are posting to a 3rd party server, this will probably be down to them.

  6. #6
    Join Date
    Oct 2004
    Posts
    3
    Quote Originally Posted by rhs98
    Code:
    <form action="http://myserver.com/dbscript.php" method="GET">
    Bill is right, you'll need to do something to stop malicous input (however unlikely you think it will be). Though, as it sounds like you are posting to a 3rd party server, this will probably be down to them.
    Thanks rhs98. So you think a simple form action to the URL of the script will work? I'm using Include() because that's what I read from PHP.net when it comes to passing variables between two different URLs. I'm going to try it and see.

    Anyway, security is being handled on the other end, my job is to get my data to their database. They've given me variable names and values to pass along which their script uses to authenticate me. I'm really new at all of this and they're very sslloooww in giving me info so I'm asking around. Thanks to all who posted

Posting Permissions

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