Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7840 > unrolled thread

Gettting values from URL in PHP 5.4

Started by"Tim Rude" <timrude.nospam@nospam.hotmail.com>
First post2012-12-18 11:50 -0600
Last post2012-12-18 14:02 -0600
Articles 5 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  Gettting values from URL in PHP 5.4 "Tim Rude" <timrude.nospam@nospam.hotmail.com> - 2012-12-18 11:50 -0600
    Re: Gettting values from URL in PHP 5.4 Salvatore <sal@yojimbo.hack.invalid> - 2012-12-18 17:55 +0000
    Re: Gettting values from URL in PHP 5.4 Christoph Becker <cmbecker69@gmx.de> - 2012-12-18 20:12 +0100
      Re: Gettting values from URL in PHP 5.4 Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-18 14:44 -0500
        Re: Gettting values from URL in PHP 5.4 "Tim Rude" <timrude.nospam@nospam.hotmail.com> - 2012-12-18 14:02 -0600

#7840 — Gettting values from URL in PHP 5.4

From"Tim Rude" <timrude.nospam@nospam.hotmail.com>
Date2012-12-18 11:50 -0600
SubjectGettting values from URL in PHP 5.4
Message-ID<kaqadm$bba$1@dont-email.me>
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+Street&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

[toc] | [next] | [standalone]


#7841

FromSalvatore <sal@yojimbo.hack.invalid>
Date2012-12-18 17:55 +0000
Message-ID<kaqam7$1sc2$1@yojimbo.hack>
In reply to#7840
On 2012-12-18, Tim Rude <timrude.nospam@nospam.hotmail.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++

[toc] | [prev] | [next] | [standalone]


#7842

FromChristoph Becker <cmbecker69@gmx.de>
Date2012-12-18 20:12 +0100
Message-ID<kaqf2q$7nr$1@speranza.aioe.org>
In reply to#7840
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

[toc] | [prev] | [next] | [standalone]


#7843

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-12-18 14:44 -0500
Message-ID<kaqh46$pck$1@dont-email.me>
In reply to#7842
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@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#7844

From"Tim Rude" <timrude.nospam@nospam.hotmail.com>
Date2012-12-18 14:02 -0600
Message-ID<kaqi54$1mm$1@dont-email.me>
In reply to#7843
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message 
news:kaqh46$pck$1@dont-email.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 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web