Re: Passing variable from webpage to php (newbie?)

From: Date: Wed, 19 Mar 2003 16:18:15 +0000
Subject: Re: Passing variable from webpage to php (newbie?)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-140292@lists.php.net to get a copy of this message
You have register_globals set to off (read up on "register globals" in php.net). your code should read $HTTP_POST_VARS['action'] or $_POST['action'] (depending on PHP version) INSTEAD of just $action. so to test an if:: if ($HTTP_POST_VARS['action']==1) { /* Code for if action is equal to 1 */ } Of course checkingif the variable is set or empty might be a good idea as well, is set example: if (isset($HTTP_POST_VARS['action'])) { /* Code if the variable POSTed is set */ } "Joe Kupiszewski" <joe@thekups.com> wrote in message news:20030319155813.42156.qmail@pb1.pair.com... > I think I already tried to post once, so sorry if this is a duplicate, but I > don't see my first attempt. I am trying to do what should be a relatively > simple and basic task. I've got a php script/page that has a switch/case > selection statement in it. Obviously, depending on what value a particular > variable takes when passed to the script, the script SHOULD :) do different > things. However, when I invoke the script using > www.somedomain.com/somephpscript.php?action=1 (substitute one with, 2, 3, 4 > or whatever) and then do a check whether any value is passed to my script, > it always tells me the value is empty ( if (empty ($action)) - it just > always thinks its empty. I'm copying this script from a book, so I do not > have any reason to believe there is an error in the code, but obviously > something is not happening properly. My thought is that perhaps something > needs to be turned on in the php.ini or in the apache httpd.conf file to > allow this variable passing to work. Is there some other way to do this? > > Sorry for the long paragraph sentence. I'll be happy to post the code if > needed or provide any additional information or give the actual URL so you > can see what is happening. > > Thanks for any thoughts > >

« previous php.general (#140292) next »