PHP Gods, Hear My Cry!

Zxcs

[H]ard|Gawd
Joined
Sep 11, 2004
Messages
2,007
I've used PHP before, but nothing past the basics, however I do understand quite a few of the commands and concepts due to their relation to C+/C++. What I wish to do is create a simple program that I will run on my web server, which will query another server, take data and mirror it.

E.g.
www.mywebserver.com/phpscript will mimic the data on www.site.com/1

However, to access www.site.com/1, you need to login via an html-based login. So when you try to connect to www.site.com/1, you get redirected to www.site.com/2 where it asks you to input user and password data in an html form.

I have an account for www.site.com/1, but I have no idea how I could get a PHP program to "send" the user/pass over when it connects to www.site.com/1, bearing in mind it uses html-based form login, not a HTTP popup.

Also, how would I get it to take data from a table? I’ve worked with xml forms a bit, taking specific values, but I’ve never tried it with html.

Hope you can help, as I would really find a use for this program when I create it.

Thanks a load!
Zxcs
 
Ok, I've never tried this...but I think it can work.

You can send custom headers with php. It seems you would be able to "forge" a http POST response to the page that the login form specifies in the action field of the form.

So what you would be doing was skipping the login form and passing your username/password to the same page that the login form sends the information to.

Some links to check out:
http://us4.php.net/curlpost (read the comments especially)
http://www.google.com/search?q=php+...ient=firefox&rls=org.mozilla:en-US:unofficial
http://www.zend.com/publishers/excerpts.php?id=17&exc=8074_Chap02
http://www.phpfreaks.com/quickcode/code/120.php

HTH
 
It will also depend what www.site.com/1, method of authenticating is. You have to figure out where the form sends the data, and simulate the send to it. If it uses POST variables, that would be the way to go. If it uses GET variables, you can just embed them in the URL you link to from your script. Ex: www.site.com/1?user=you&pass=word. However, if they are using session variables or cookies, you would need to simulate those instead. Each are equally easy in PHP, just search the PHP manual for "session" or "cookies".
 
Back
Top