chopficaro — 2012-08-19T23:33:16-04:00 — #1
ok try to follow me on this one
i have a form
when i press submit, it goes to a php page
i want that php page to make a http request
i want the html returned from that http request returned to me as a string, so i can do something with it and display data on the php page accordingly
sorry if that sounds confusing, i explained it as best i could
dresden_phoenix — 2012-08-19T23:55:55-04:00 — #2
Conversely ( I only say this because you mentioned pressing submit) ... you could have the form target its OWN PAGE. A a script at the top of the page could check to see if the form has been submitted ( give the submit button a name and value, check for the presence of that variable with the script. eg. ( assuming you use GET method for the form).:
<? if (isset($_GET['submit']) : ?>
..your stuff processing/output code here
..your fom code here
<? endif ?>
hope that helps
chopficaro — 2012-08-20T02:01:23-04:00 — #3
no, ill try to explain differently
i guess the form doesnt have anything to do with it
when the php page loads, i want it to make an http request, and return the html as a string, so that i can use the html in different ways when the php page finishes loading and displays for the user
dresden_phoenix — 2012-08-20T02:12:00-04:00 — #4
Unless you use ajax ( which essentially uses .js to call another document for a http request) , you can output anything to a page after the header has been sent.
when the php page loads, i want it to make an http request, and return the html as a string, so that i can use the html in different ways when the php page finishes loading and displays for the user Essentially correspond to the same point in time... so that's why its hard to understand what what your goal is.
If you want to SAVE the HTML for use in another page... you could session_start(), write the whole HTML into a string variable (lest say: $html) before the header is sent. then echo $html; ( this ouputs your page for the user) , then store the string for latter use with $_SESSION['html']=$html;
markdidj — 2012-08-20T06:04:12-04:00 — #5
The way I'd do your particular script is set an include to output just the result from the form, and place it in the directory structure where it can be called both server-side and client-side. Call it server-side in the usual way...
// create page before form output
// create page after form output
<input type="submit" onclick="changeScript('formOutput.php?live=1&formValue1='+input1.value+'&formValue2='+input2.value); return false" />
To output just the string you require without executing the rest of the page (or skipping the bits that output when live is false)
I hope you've got the gist of it. I'm not very good at writing about it. Good at using it though
logic_earth — 2012-08-20T07:29:16-04:00 — #6
markdidj — 2012-08-20T07:41:34-04:00 — #7
That's not unusual for me here!
Maybe I'm a bit dyslexic, never been diagnosed but I do wonder sometimes.
It might give him/her some inspiration.
chopficaro — 2012-08-20T12:48:06-04:00 — #8
lol logic earth is correct that is what i need, curl
i seem to faintly remember trying to use curl but having trouble "installing" it or something, like the server had to have it installed
markdidj — 2012-08-20T19:20:46-04:00 — #9
I think cURL can do a lot more though. Isn't it used to get images from one server to another? I'll ask in another thread.
EDIT:: Actually, a lot of errors in reading a page as XML using that method! But I would go along the lines of reading the page as XML if you can.