Page 1 of 1

TRIVIAL!- Extra assigment of $_POST

PostPosted: 27. April 2013 21:25
by AAA123
While moving on the old php scripts working with Apache1.3 and php4.3
-> to the XAMPP (apache2.4 php5) - the following problem arose.
In (XAMPP) a simple php script containing a form and sending your entries
back to the script I have to load them again with the predefined variables $ _GET or $ _POST

Code: Select all
       $enterd_value = $_POST['enterd_value'];     <---- is it really needed ?
   if ($enterd_value)
     echo "$enterd_value";
   else
     print '<FORM action="script.php" method="POST">';
     print '<INPUT type="text" name="entered_value">';

Re: TRIVIAL!- Extra assigment of $_POST

PostPosted: 28. April 2013 06:48
by Moore
Hi, sounds like you may have had 'Register Globals' enabled in php 4, which is generally considered a bad practice since it can potentially allow ANYONE to create/inject their own global variables into your scripts, not just you.

You can find lots of documentation on how to emulate Register Globals. Just keep in mind this 'feature' has been removed from PHP altogether for good reasons..

Warning
This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.


More info:
http://php.net/manual/en/security.globals.php
http://www.php.net/manual/en/faq.misc.php#faq.misc.registerglobals
http://en.wikibooks.org/wiki/PHP_Programming/Register_Globals
http://www.reddit.com/r/PHP/comments/13gdmb/so_i_found_out_register_globals_on_is_bad_now_my/

And more good advice:
http://community.apachefriends.org/f/viewtopic.php?f=16&t=43608&p=171052#p171058

This might be useful too (migrating from php4 to php5):
http://www.php.net/manual/en/migration5.php

Re: TRIVIAL!- Extra assigment of $_POST

PostPosted: 28. April 2013 08:00
by AAA123
Thank you - I understand that the assignment is needed to have $entered_value not empty.