FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Gettting values from URL in PHP 5.4
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Gettting values from URL in PHP 5.4 [message #179908] Tue, 18 December 2012 12:50 Go to next message
Tim Rude is currently offline  Tim Rude
Messages: 2
Registered: December 2012
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Sorry if this is a dumb question. I'm a PHP novice.

We have been using PHP 4 on a page in our website to pre-populate some text
boxes on a form. The text is passed as part of the URL.

Here's a sample url showing how the data is passed:

http://www.samplesite.com/mypage.php?name=Sample+Name&addr=123+Main+Str eet&city=Sometown%2C+AL+12354

Here's the code I use on the page to populate the form boxes:

<input type="text" name="on0" maxlength="40" value="<?php echo $name; ?>">
<input type="text" name="os0" maxlength="40" value="<?php echo $addr; ?>">
<input type="text" name="on1" maxlength="40" value="<?php echo $city; ?>">

With PHP 4, it works perfectly.

Now our hosting provider is updating from PHP 4 to PHP 5.4. But with PHP
5.4, none of the form boxes get populated. There's no error message or
anything, it just simply leaves the form boxes blank as if nothing was
passed via the URL.

What do I need to do to get it working with PHP 5.4?

Tim Rude
Re: Gettting values from URL in PHP 5.4 [message #179909 is a reply to message #179908] Tue, 18 December 2012 12:55 Go to previous messageGo to next message
Salvatore is currently offline  Salvatore
Messages: 38
Registered: September 2012
Karma: 0
Member
add to buddy list
ignore all messages by this user
On 2012-12-18, Tim Rude <timrude(dot)nospam(at)nospam(dot)hotmail(dot)com> wrote:
> Here's the code I use on the page to populate the form boxes:
>
> <input type="text" name="on0" maxlength="40" value="<?php echo $name; ?>">
> <input type="text" name="os0" maxlength="40" value="<?php echo $addr; ?>">
> <input type="text" name="on1" maxlength="40" value="<?php echo $city; ?>">
>
> With PHP 4, it works perfectly.

If you wrote your code like that throughout your site, you have a lot of
editing to do. The correct way to reference a request variable is
$_REQUEST['key']. So replace "$name" with "$_REQUEST['name'] and repeat
that step for the other values.

--
Blah blah bleh...
GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
Re: Gettting values from URL in PHP 5.4 [message #179910 is a reply to message #179908] Tue, 18 December 2012 14:12 Go to previous messageGo to next message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma: 0
Member
add to buddy list
ignore all messages by this user
Tim Rude wrote:
> With PHP 4, it works perfectly.

The working of the code is actually not directly related to the PHP
version, but to the PHP ini setting "register_globals"
(<http://php.net/manual/en/security.globals.php>). This setting has
been finally removed from PHP 5.4.

How to fix your existing code has already been explained by Salvatore.
I would prefer using $_GET, $_POST or $_COOKIE instead of $_REQUEST.

--
Christoph M. Becker
Re: Gettting values from URL in PHP 5.4 [message #179911 is a reply to message #179910] Tue, 18 December 2012 14:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On 12/18/2012 2:12 PM, Christoph Becker wrote:
> Tim Rude wrote:
>> With PHP 4, it works perfectly.
>
> The working of the code is actually not directly related to the PHP
> version, but to the PHP ini setting "register_globals"
> (<http://php.net/manual/en/security.globals.php>). This setting has
> been finally removed from PHP 5.4.
>
> How to fix your existing code has already been explained by Salvatore.
> I would prefer using $_GET, $_POST or $_COOKIE instead of $_REQUEST.
>

I agree. Use the proper array - $_GET, $_POST or $_COOKIE.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Gettting values from URL in PHP 5.4 [message #179912 is a reply to message #179911] Tue, 18 December 2012 15:02 Go to previous message
Tim Rude is currently offline  Tim Rude
Messages: 2
Registered: December 2012
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
"Jerry Stuckle" <jstucklex(at)attglobal(dot)net> wrote in message
news:kaqh46$pck$1(at)dont-email(dot)me...
> On 12/18/2012 2:12 PM, Christoph Becker wrote:
>> Tim Rude wrote:
>>> With PHP 4, it works perfectly.
>>
>> The working of the code is actually not directly related to the PHP
>> version, but to the PHP ini setting "register_globals"
>> (<http://php.net/manual/en/security.globals.php>). This setting has
>> been finally removed from PHP 5.4.
>>
>> How to fix your existing code has already been explained by Salvatore.
>> I would prefer using $_GET, $_POST or $_COOKIE instead of $_REQUEST.
>>
>
> I agree. Use the proper array - $_GET, $_POST or $_COOKIE.
>

Thank you all. Fortunately I only have this code in 6 spots on one page, so
it's an easy fix to add the $_GET.

Much obliged. :)

Tim Rude
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Dynamic redirect - losing variable
Next Topic: HP syntax error, unexpected T_variable
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Oct 21 13:44:32 EDT 2017

Total time taken to generate the page: 0.00561 seconds