php-windows Digest 13 Jun 2003 07:30:34 -0000 Issue 1774
Topics (messages 20293 through 20300):
Re: Cannot access HTTP_POST_VARS without explicitly stating
20293 by: DvDmanDT
20294 by: Jeremy
Re: $GLOBALS
20295 by: Adam Goossens
20296 by: Adam Goossens
20299 by: DvDmanDT
more on HTTP post variables
20297 by: weifan agusman
20298 by: Steve Yates
20300 by: Svensson, B.A.T. (HKG)
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
register_globals in php.ini should be set to On in order for that to work...
"Jeremy" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I am having an issue with my server. I'm relatively new to PHP, so I've
> been looking over a lot of tutorials and articles lately. One common
theme
> (and the reason I'm using PHP) is forms. The code typically uses an echo
to
> pull the variabl from the HTTP_POST_VARS without explicitly stating it.
IE,
> the tutorials use $name instad of $HTTP_POST_VARS["name"].
>
> My problem is this, if I use $HTTP_POST_VARS["name"], it works just fine.
> If I just try to use $name, it shows up empty. The rest of the code will
> work fine. Any thoughts?
>
>
--- End Message ---
--- Begin Message ---
Thanks. I was under the impression that those with an opposite problem had
to enable the value. I had just come across this solution earlier today and
was going ot try it when I get the chance.
"Dvdmandt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> register_globals in php.ini should be set to On in order for that to
work...
> "Jeremy" <[EMAIL PROTECTED]> skrev i meddelandet
> news:[EMAIL PROTECTED]
> > I am having an issue with my server. I'm relatively new to PHP, so I've
> > been looking over a lot of tutorials and articles lately. One common
> theme
> > (and the reason I'm using PHP) is forms. The code typically uses an
echo
> to
> > pull the variabl from the HTTP_POST_VARS without explicitly stating it.
> IE,
> > the tutorials use $name instad of $HTTP_POST_VARS["name"].
> >
> > My problem is this, if I use $HTTP_POST_VARS["name"], it works just
fine.
> > If I just try to use $name, it shows up empty. The rest of the code
will
> > work fine. Any thoughts?
> >
> >
>
>
--- End Message ---
--- Begin Message ---
Mike,
The $GLOBALS array contains references to all variables defined in the global
scope. By using the keyword global, you define a variable in the global scope
(and then make it accessible through $GLOBALS).
The superglobals (eg _POST, _GET, etc) don't get this automatically, because
they are "scopeless".
It would only work if you used the following code beforehand:
global $_POST['photo'];
hth.
--
Adam Goossens
=======================================
Quoting [EMAIL PROTECTED]:
>
>When running the following code:
>
>foreach($GLOBALS['photo'] as $photo)
>
>I get:
>
>Warning: Invalid argument supplied for foreach() on line 63
>
>Would register globals have to be on for this code to work? Am I using the
>$GLOBALS clause wrong? It would seem to me that this should work since you
>can use post in the same fashion.
>ie: foreach($_POST['photo'] as $photo)
>
>~ Mike
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--- End Message ---
--- Begin Message ---
Oh, and to answer your original question: yes, as far as I am aware
register_globals would have to be on for that code to work.
--
Adam Goossens
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--- End Message ---
--- Begin Message ---
Hmm... I think the first part of foreach should be an array... So, more
like
foreach($GLOBALS as $photo)... Unless photo is an array containing photos...
However, how to make a variable become global, I'm not sure of...
"Mike" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> When running the following code:
>
> foreach($GLOBALS['photo'] as $photo)
>
> I get:
>
> Warning: Invalid argument supplied for foreach() on line 63
>
> Would register globals have to be on for this code to work? Am I using
the
> $GLOBALS clause wrong? It would seem to me that this should work since
you
> can use post in the same fashion.
> ie: foreach($_POST['photo'] as $photo)
>
> ~ Mike
>
>
--- End Message ---
--- Begin Message ---
Another newbie on PHP here. say I have this simple PHP code:
<HTML><HEAD>
<TITLE>Simple Input</TITLE>
</HEAD><BODY>
<FORM ACTION="post.php" METHOD="post">
Your name: <BR>
<INPUT TYPE="text" NAME="name"><BR>
<INPUT TYPE="submit">
<INPUT TYPE="reset"></FORM>
</BODY></HTML>
So I'm sending 'name' to post.php but I also want to send another variable, say
'school' which has a fixed default value. But of course I dont need to (and don't want
to) put the 'school' field on the form.
So question is how do I send the school value when the submit button is pressed?
thanks in advance.
weifan
____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] (Weifan Agusman) wrote in
news:[EMAIL PROTECTED]:
> I dont need to (and don't want to) put the 'school' field on the form.
This is actually an HTML question. Use:
<input type="hidden" name="school" value="Pepperdine">
- Steve Yates
- * <- Tribble. ! <- Tribble With A Mohawk.
~ Taglines by Taglinator - www.srtware.com ~
--- End Message ---
--- Begin Message ---
> But of course I dont need to (and don't want to) put
> the 'school' field on the form.
That's wise since it would constitute a possible security
hole by doing so.
> So question is how do I send the school value when
> the submit button is pressed?
This is an contradictive requirement compared to the previous one.
You can not do it! Either you send the variable via the FROM with
the HTML-tag HIDDEN (breaks first requirements), or you keep some
kind of session state variables on the server side (breaks second
requirments), but you can't do it both.
It up to you wich one of the requriments you want to drop. ;)
--- End Message ---