This is a discussion on read from standard input? within the PHP Language forums, part of the PHP Programming Forums category; Hobart Runa Sze schrieb: > I read that passing data via POST means PHP running as CGI needs to > ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hobart Runa Sze schrieb:
> I read that passing data via POST means PHP running as CGI needs to > read from standard input buffer instead of global vars. I tried reading > from $_POST but can't find my data there. > > I searched the manual for a function to read from stdin but couldn't > find any. Does it even exist or do we always use $_POST? Use $_POST when PHP is running in the context of a webserver. If you use PHP from the command line there will be no $_POST. Regards, Matthias |
|
|||
|
Hello,
I read that passing data via POST means PHP running as CGI needs to read from standard input buffer instead of global vars. I tried reading from $_POST but can't find my data there. I searched the manual for a function to read from stdin but couldn't find any. Does it even exist or do we always use $_POST? Any help is appreciated, Hobart |
|
|||
|
On 2004-06-02, Hobart Runa Sze <hobartsze@h0tmail.com> wrote:
> I searched the manual for a function to read from stdin You don't want it in this case, but reading from stdin: $fp = fopen('php://stdin', 'r'); while($line = fgets($fp, 4096) { echo $line; } HTH, phil -- Please send replies (not followups) to the address set in Reply-To. Philipp Kern - PK2186-RIPE - http://www.philkern.de |
|
|||
|
>
> Use $_POST when PHP is running in the context of a webserver. If you use > PHP from the command line there will be no $_POST. > > Regards, > Matthias Thanks for clearing that up, Matthias. However I still this problem... My script gets run when a form is submitted. If action="write.php", everything works fine - I can read $_POST["data"]. If action="write.cgi", the script runs and prints out the hardcoded text but when echoing $_POST["data"] nothing comes out. What could possibly be the reason? Hobart |
|
|||
|
On 2004-06-03, Hobart Runa Sze <hobartsze@h0tmail.com> wrote:
> If action="write.cgi", the script runs and prints out the hardcoded text > but when echoing $_POST["data"] nothing comes out. > What could possibly be the reason? PHP is not invoked when the script is named .cgi? Bye, phil -- Please send replies (not followups) to the address set in Reply-To. Philipp Kern - PK2186-RIPE - http://www.philkern.de |
|
|||
|
Regarding this well-known quote, often attributed to Philipp Kern's famous
"3 Jun 2004 08:58:23 GMT" speech: > On 2004-06-03, Hobart Runa Sze <hobartsze@h0tmail.com> wrote: >> If action="write.cgi", the script runs and prints out the hardcoded text >> but when echoing $_POST["data"] nothing comes out. >> What could possibly be the reason? > > PHP is not invoked when the script is named .cgi? > > Bye, > phil You can run PHP either as an Apache module (how it usually is), or as a CGI app. -- -- Rudy Fleminger -- sp@mmers.and.evil.ones.will.bow-down-to.us (put "Hey!" in the Subject line for priority processing!) -- http://www.pixelsaredead.com |
|
|||
|
FLEB schrieb:
> Regarding this well-known quote, often attributed to Philipp Kern's famous > "3 Jun 2004 08:58:23 GMT" speech: > >> PHP is not invoked when the script is named .cgi? > > You can run PHP either as an Apache module (how it usually is), or as a CGI > app. Yes, but my scripts still have the extension ".php", even when I use PHP as a CGI application. Regards, Matthias |
|
|||
|
Matthias Esken wrote:
> FLEB schrieb: > > >>Regarding this well-known quote, often attributed to Philipp Kern's famous >>"3 Jun 2004 08:58:23 GMT" speech: >> >> >>>PHP is not invoked when the script is named .cgi? >> >>You can run PHP either as an Apache module (how it usually is), or as a CGI >>app. > > > Yes, but my scripts still have the extension ".php", even when I use PHP > as a CGI application. > > Regards, > Matthias Yea, my host requires all cgi scripts to be names *.cgi for security reasons. |