Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Pass form data from one server to another server

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-17-04, 08:58
Jred Jred is offline
Registered User
 
Join Date: Oct 2004
Posts: 3
Question 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?
Reply With Quote
  #2 (permalink)  
Old 10-17-04, 13:54
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 525
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
Reply With Quote
  #3 (permalink)  
Old 10-17-04, 16:08
Jred Jred is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 10-17-04, 23:24
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 525
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
Reply With Quote
  #5 (permalink)  
Old 10-21-04, 05:39
rhs98 rhs98 is offline
Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 440
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.
Reply With Quote
  #6 (permalink)  
Old 10-21-04, 06:42
Jred Jred is offline
Registered User
 
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On