Page 1 of 2
POSTing without a form
Posted: Wed Nov 12, 2003 8:17 am
by maniac9
Is there a simple way to send POST data to another script without the use of a visible form, and automatically - ie. open one page (maybe directly in PHP) and have some data sent to another script
Posted: Wed Nov 12, 2003 8:25 am
by infolock
not quite sure what you are asking, but maybe this is close to it.
if you have a variable on a page that you would like to use on another, the best way is to call the include() function.
Example :
you have a php page called bob.php
in it is the following :
and you have another php page called george.php that you want to call bob.php's variable $this.
So, you would do it like so :
Code: Select all
<?php
ob_start();
include "bob.php";
echo ''.$this.' World!';
ob_end_flush();
?>
Another method is to use Sessions()
you can view information on them here : [php_man]Session[/php_man]
hope that helps.
Posted: Wed Nov 12, 2003 8:29 am
by hedge
I have done it using fsockopen check out this link
viewtopic.php?t=7063
BTW the function 'httpParseResponse' in my code is incorrect. It explodes by \r\n\r\n when it should just split the headers from the content at the first occurrance of \r\n\r\n
Posted: Wed Nov 12, 2003 8:34 am
by genetix
Do you kind of mean a link?
I would suggest this. (in steps)
first page: automatically sends a user to next pag with variable:
http://www.yoursite.com/index.php?variable=value
second page: The page you send users to with new info.
Posted: Wed Nov 12, 2003 8:35 am
by maniac9
well, like that, but instead of using GET, using POST
Posted: Wed Nov 12, 2003 8:57 am
by infolock
any way we can check the code to see what you are talking about?
Posted: Wed Nov 12, 2003 9:17 am
by maniac9
well i dont have any yet
Here's a simple description of the scenario...
I need to send a large amount of text from one script to another, and the limitations of GET will be in the way, so I need to POST it. However, the text being sent will be generated from another source, not by a user. Therefore, what I need is a way for one script to take some text, send it via POST (but transparent to the user) to another script.
Posted: Wed Nov 12, 2003 9:26 am
by twigletmac
Could you use sessions for this?
Mac
Posted: Wed Nov 12, 2003 9:31 am
by itsmani1
wel u can use hidden fields but u hav to use form to in that case....
Posted: Wed Nov 12, 2003 9:37 am
by m3mn0n
I agree.
Hidden fields and javascript auto submit.
Or cookies/sessions to save the data and gather it on the next page.
Posted: Wed Nov 12, 2003 9:54 am
by qads
if the data is larger then 4kb then you cant use cookies

, may wanna stick with sessions

.
Posted: Wed Nov 12, 2003 10:29 am
by maniac9
well, the problem with using sessions is the fact that the data could be coming from another language
i think what im going to do is hidden forms with a javascript autosubmit like Sami suggested - seems like my only option
Posted: Wed Nov 12, 2003 11:58 am
by hedge
OK, am I invisible here? Did you consider the option I suggested?
Posted: Wed Nov 12, 2003 12:03 pm
by mrvanjohnson
who said that

Posted: Wed Nov 12, 2003 1:26 pm
by JAM
Just out of curiosity... Why $_POST?
As Mac (and others) sais, $_SESSION is the obvious choise imho, for 'invisible' data transport.