Re: Cannot get data from form.

From: Date: Thu, 29 Aug 2002 15:30:43 +0000
Subject: Re: Cannot get data from form.
Groups: php.general 
Request: Send a blank email to php-general+get-114515@lists.php.net to get a copy of this message
Turning off register globals and referencing variables through the new array syntax certainly gives a greater degree of control over the origin of data; ie: a variable referenced $_POST['foo'] has (most likely) been received as a result of http post and it's reasonably safe to assume $_COOKIE['foo'] is a value from a cookie etc. In this example with globals=on $foo could have come from anywhere... The only thing i've found a bit annoying is when a value can be passed variously by a form (method=post) or as a query string value appended to a link uri. Writing... if (isset($_GET['foo'])) { $foo = $_GET['foo'] } elseif (isset($_POST['foo'])) { $foo = $_POST['foo'] } when I want to use $foo is a bit annoying, but i haven't figured out a more elegant way of saying this yet. Javier
That's the way it works in the newer PHP for security reasons. I had to rewrite all my code about a week ago because my client was using php 4.2 and I had 4.0. It has to do with the Globals are set to being turned off in the php.ini file. You should be able to change the php.ini file to globals on, but people will argue that it's a security problem and you should just change all your global varieables to the new way. It's your call. Hope this helps. Brian Le Van Thanh wrote:
- I have installed PHP4.2.2 with Apache 1.3.26 on Solaris7. And now I have problems with getting data from form. I have 2 pages test.html and welcome.php as following: ----------------test.html---------------------------------------------------- <form "userDetails" method="post" action="welcome.php">
    Enter your Name: <br>
    <input type="text"  value="" name="name">
    <input type="submit" value="Enter" name="welcome">
</form> ------------------------------welcome.html--------------------------------- ?php
    print  $name ;
?> =============================== Then I cannot get the value of input name. But if I write " print $_POST['name'];" or " print $HTTP_POST_VARS['name'];", it's ok. Is there something wrong when I install PHP? Thanks a lot.
-- Brian Windsor Giant Studios Senior Technical Director of Motion Capture brian@giantstudios.com (404)367-1999 _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com

« previous php.general (#114515) next »