Probably a simple $_GET question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
prizo
Forum Newbie
Posts: 4
Joined: Wed Jan 28, 2009 6:40 pm

Probably a simple $_GET question

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Probably a simple $_GET question

Post by Christopher »

Given you example you are very, very lost. ;) What are you trying to do?
(#10850)
prizo
Forum Newbie
Posts: 4
Joined: Wed Jan 28, 2009 6:40 pm

Re: Probably a simple $_GET question

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Probably a simple $_GET question

Post 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.
(#10850)
prizo
Forum Newbie
Posts: 4
Joined: Wed Jan 28, 2009 6:40 pm

Re: Probably a simple $_GET question

Post by prizo »

So:

Code: Select all

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

Should work?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Probably a simple $_GET question

Post by Christopher »

prizo wrote:Should work?
It would be easier to try it than post a question. So, did it work?
(#10850)
prizo
Forum Newbie
Posts: 4
Joined: Wed Jan 28, 2009 6:40 pm

Re: Probably a simple $_GET question

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Probably a simple $_GET question

Post 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.
(#10850)
Post Reply