Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

can't get the value of fields in a form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

can't get the value of fields in a form

Postby j_bravo » Thu Mar 20, 2003 3:56 pm

i;ve just installed apache 2.0 and php 4.3.0 for win32 and i just cannot get the values of the fields i use in a form... even though when i submit the form i get the url "test.php?var=etc", if i try to echo $var, it will show ''...what can i do ?

10x ;)
User avatar
j_bravo
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Mar 20, 2003 3:48 pm

Postby Skeletor » Thu Mar 20, 2003 5:53 pm

use either one of these two things:
$_GET['var']
$_REQUEST['var']

you can't access the $var directly unless your global variables setting is turned on.
Skeletor
New php-forum User
New php-forum User
 
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

Postby Xerpher » Thu Mar 20, 2003 6:46 pm

I have never heard of / used $_REQUEST, but for forms I use $_POST
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby Skeletor » Fri Mar 21, 2003 4:30 am

http://www.php.net/manual/en/reserved.variables.php

It's an associative array consisting of $_GET, $_POST, and $_COOKIE variables. If you use $_REQUEST, you can access either get, post, or cookie variables.

It looked like he was referencing it from a URL, so that's why I recommended either $_GET or $_REQUEST. $_REQUEST is just a handy one to use if you don't know where it's coming from.
Skeletor
New php-forum User
New php-forum User
 
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

Postby Oleg Butuzov » Sat Mar 22, 2003 11:36 pm

read change log.

register globals!
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Redcircle » Wed Sep 24, 2003 10:09 pm

try

echo $_REQUEST['firstname'];
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

GET & POST

Postby ruturajv » Wed Sep 24, 2003 11:01 pm

Depending upon your info travelling path

It is always better to use
$_GET['var_name']
$_POST['var_name']
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby psychomantum » Thu Sep 25, 2003 9:43 pm

I would also suggest that you stick to this method and not register globals. I made the mistake of learning with register globals on, and I learned the hard way that it is a security risk, not to mention it can get sloppy.

There is no space between $_REQUEST and the ['var'], it's all one entity, $_REQUEST['var']

Just please, please DO NOT REGISTER GLOBALS!
psychomantum
New php-forum User
New php-forum User
 
Posts: 10
Joined: Sat Dec 07, 2002 8:04 pm

Sticky Announcement

Postby ruturajv » Thu Sep 25, 2003 9:47 pm

Please read a sticky or the announcement on the PHP General group writen by one of our Mod, Very necessary you read it
TURN OFF REGISTER GLOBALS
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron