Page 1 of 1

Probably a simple $_GET question

Posted: Wed Jan 28, 2009 7:09 pm
by prizo
I searched for 'get' and $_GET and got no results so...

I want to perform this this GET function, but in php:

Code: Select all

<FORM METHOD=GET ACTION="http://www.w3schools.com/XML/note.xml">
        <INPUT TYPE=SUBMIT>
</FORM>
 
How do I do this? Any info I'vefound is far more advanced so it inevitably loses me.

Re: Probably a simple $_GET question

Posted: Wed Jan 28, 2009 11:35 pm
by Christopher
Given you example you are very, very lost. ;) What are you trying to do?

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 12:48 am
by prizo
Ha!
Yes.. I know very little about gets, posts and the like. I've programmed Java for years but never had to deal with this stuff.

That HTML (once clicking the submit button) does what I want... but I'd like to be able to do it within php so I can then manipulate the xml that the 'get' returns. I dont want to just 'echo' the html either.
I realize that I may be going about this the completely wrong way and if I am please, SHOW ME THE LIGHT! :)

From another site "The GET method is used to retrieve web pages from the server."
Well... I want to do that. I want a submit button that runs a php script that gets xml (just like my html example) and saves that xml to a file on a local drive.

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 2:00 am
by Christopher
Do you want to fetch the file 'http://www.w3schools.com/XML/note.xml' ? With PHP you would probably use the cURL or simpleXML library. See the docs.

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 10:05 am
by prizo
So:

Code: Select all

$file = "http://www.w3schools.com/XML/note.xml";
$xml = simplexml_load_file($file)

Should work?

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 1:26 pm
by Christopher
prizo wrote:Should work?
It would be easier to try it than post a question. So, did it work?

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 4:29 pm
by prizo
I totally agree, arborint, but I don't have my dev machine here (at work) so I haven't been able to try it out.

I intend to try this out when I get home but I was hoping that there may be some advice before then, if its bound to fail.

Re: Probably a simple $_GET question

Posted: Thu Jan 29, 2009 5:14 pm
by Christopher
If the server has HTTP stream wrappers enabled then it should work. If not you will need to use cURL. So it depends.