Is there ANY WAY that I can use PHP to automatically fill in a form on another website than my own?
Currently, the user submits data to me, which is stored in a DB. If they want the data to appear on another site, they must then type it into the other site.
I was thinking of building a form where the user types the data into it, it runs off and submits it elsewhere and then the confirmation page of the other site pops up.
It doesn't sound possible to me. php is a server side scripting language that operates on pages you serve to your clients. When you become a client of another site, php is not available for you to send pages to that site's server. That is going in the reverse direction.
Furthermore, it seems to me that php requires a client to trigger something through a link or a submit button to execute a php script. So, let's say you go to another site, and the site displays the form. What would be your trigger to get your php script to start execution and fill in the form?
Well actually there is a fairly complicated way but it may not always work.
You need to build a header in PHP that redirects you to the form handler on the other site, sends the variables properly (the same thing that would happen if a form is submitted). But it is pretty complicated and not guaranteed to work (depending on the setup of the otehr site)
What about opening a scoket connection to the server in question and simulating a post to the url in question?
Actually there is a easy way to do it, well with the help of a class called snoopy:
The class simulates a browser. Among some of it's functions is filling in and submitting forms. So pass your first form's variables to this class, give it a submit URL and your set. It also will give you the results or response from the server you submitted to, with which you can maniplulate however you want.
It even passes "basic" authorization for the submit pages that may require it. Other authorization, good luck. If you find out, PLEASE let me know.
I'm basically building an auction manager for use with Ebay and I'm trying to code a tool that will submit auctions to Ebay based on our user's preferences/templates/information etc.
I just tried Snoopy, but although it attempted to submit to Ebay, can pull Ebay's form items etc from Ebay's pages, it will not just jump straight to the "Confirm/Preview" screen on Ebay.co.uk.
When I try it, it takes me to the "Photo Hosting Preferences" page, which would be defunct in this case as the user would store their images on our server, rather than the incredibly slow and unreliable IPix that Ebay currently uses.
I think that the "Photo Hosting Preferences" are stored as a cookie. Might have to search around my HDD and see if I can find the variables that switch it off.
Thanks for the help, gonna try some more tomorrow...must sleep now.......YAWN......
I don't know if this makes a difference, but I use snoppy a little different way. I Get the form elements ahead of time, instead of pulling them from the site. For each form input, I use $submit_vars["formelementname"] = "$value"; Of course $value could be static or a variable. Also make sure you put in a referer and even sometimes "submit" buttons have values.
Maybe some of that elements are hidden? Just a thought.
The only trouble I've had is where there is authorization that is not "basic", like validating against database with a cgi script. And no ones had a solution..:(