PDA

View Full Version : Small Problem, PHP. ;(


Spherian
09-11-2002, 07:45 AM
Hello,

I have a smallish problem, and i was wondering if anyone could help me, here goes.

I have a script called submit.php and one called submitmass.php and another script called minisubmit.php.

I Also have a script called submit1.php And this script i have 10 fields of information, that a user puts in, ie. name, email age etc etc. I need this script (Submit1.php) to send the information to all of the other scripts.

Basically its like the action command in HTML, but to send it to different scripts. Any help would really be appreciated. :)

nex
09-11-2002, 07:52 AM
Why not just make them all one script?

Spherian
09-11-2002, 07:58 AM
No no no, it cant be done, I need something that submits the same information to different scripts, on different servers.

Thanks anyway. :)

nex
09-11-2002, 08:26 AM
Well if it's not absolutely vital for them to use POST data, you could just have them use GET data and make the main script readfile() all the other scripts.

Or you could use a Location header to chain each of the scripts. I'm pretty sure if you redirect a browser that way it'll send the POST data again wherever you point it.

Depends on what you're trying to accomplish, really.

Spherian
09-11-2002, 09:46 AM
Okay, i will explain. maybe it may help abit.

All the .php files are connected to a database, when i send the information to these files the information gets added to that database. I need a bit of advice of how to get my first page (where people input the information) to be sent to all these different files.

So, i enter all my information, and then press submit, and the script sends all the information i just entered to all the other scripts, which adds my information to the databse.

Really, all i need is some advice of how to send to multiple scripts. :)

Thanks Again..; :)

stuka
09-11-2002, 12:51 PM
If all of these scripts are connected to the same DB, what's the need for sending the data to multiple scripts? If they are multiple separate DB's, are they supposed to contain the same data? If so, DB replication/synchronization would be the 'correct' way to handle the situation.

Spherian
09-11-2002, 03:50 PM
Okay, data is sent to different scripts, on different servers. With different database.

stuka
09-11-2002, 05:28 PM
Hmmm....how about creating a daisy-chain: send the data to one script, which processes it and passes it on to another, and so on?

Spherian
09-11-2002, 06:22 PM
No not possible.

Thanks 4 ur help people, i think i will have to learn more basic stuff before i try this advanced stuff. :( Thanks again people. :)

stuka
09-11-2002, 07:18 PM
I really don't think you can do this with a straight-forward script approach without some kind of daisy-chaining in pure PHP. An ugly, but possibly effective, solution, would tie your submit button to a javascript function that was created with the PHP variables from the form, and launched a separate browser window for each submit script - it'd look ugly as homemade sin, but would fit the limitations you've mentioned so far...

nex
09-11-2002, 08:59 PM
you could try playing with php's socket functions..

roninblade
09-11-2002, 09:41 PM
maybe you could post the data to a new window with frames wherein the framesets are the pages you need to post the data to. the "frame page" could then pass the variables through the url of the submit pages.

<frameset src="submit.php?var1=<?=$_POST["var1"]?>">

something like that. then, you could also have seperate frame with a closing page that closes the window automatically after a few seconds. the frames of the submit pages dont have to be viewable at all; you can make the closing page the only frame that can be viewed. ;) hmmm... i hope you got that clear. HTH. :D

Hawk
09-12-2002, 09:14 AM
Submit to a script which retreives the other three scripts, in sequence, from their respective hosts via PHP's HTTP capabilities.

This will "solve" your problem, but the problem itself is the result of (very) poor implementation in the first place. However, without knowing what you're trying to do, exactly, I can't tell you what the "right" way is.

Grizzly
09-12-2002, 10:47 AM
My thoughts exactly Hawk. This is a problem of poooor application design in the first place. Anything you do to smooth over this problem will be nothing more than a "HACK", which should be considered temporary until you can work out a better data model for your application. Having the same "live" data in 10 different places is never a good idea.

Uranium-235
09-12-2002, 11:57 AM
you can just file("http://...other scripts"); and pass in the data through the url

not the smartest nor most efficient thing but it should work

nex
09-12-2002, 01:54 PM
I imagine he's making something that works with other scripts on other servers that are out of his control. Like a bunch of different search engines, or some other kind of listings (dating ads?)

Anyway, all these different places probably are only set up to accept POST'd data, so using file() or readfile() on them won't work. As far as I know, PHP doesn't have any builtin functions for posting data to remote servers.

But comments in the PHP manual led me to these:
http://px.sklar.com/code-pretty.html?code_id=313
ftp://ftp.holotech.net/postit.zip

I think this is what you want.

Uranium-235
09-12-2002, 02:45 PM
yeah file() uses the get method

it is possible to send them into the other scripts using the socket functions, but I don't know the exact format for passing in headers

iDxMan
09-15-2002, 02:13 PM
or if you have/can install the curl package:

http://www.php.net/manual/en/ref.curl.php