Methord="POST" doesn't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MarcusThe3rd
Forum Newbie
Posts: 3
Joined: Tue Nov 02, 2004 5:03 am
Location: Thailand
Contact:

Methord="POST" doesn't work

Post by MarcusThe3rd »

Dear All,
I have installed PHP on a win2000 machine. The problem is that I cant pass data (Form variables) from one page to another with "POST" methord. At the same time the "GET" Methord works.

But I later came to know that I could use this code to over come the problem:

Code: Select all

<form.....>
<input type=textbox name="NAME_OF_CONTROL">
</form>

Code: Select all

<?php
 $variable = $HTTP_GET_VARS['NAME_OF_CONTROL'];
?>
But I have used PHP on a UNIX server where I need not use this code. I could use the variable directly.

Code: Select all

<?php echo $NAME_OF_CONTROL; ?>
Could any one tell me why this is so?

My register_globals is off

Thank you

Weirdan | I request you to limit the amount of markup you use in your posts.

Weirdan | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

you will want to check this out http://uk.php.net/language.variables.predefined as it will explain why.
the short of it is under older verisons of php you could do what you where doing because a feature called register_globals was turned on by default, now it is turned off for security issues.
You can modify your php.ini file(if your host will let you) and turn register_globals=on to solve your immidiate problem while you go back and change your code.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Just to note,

if your page has extension .htm or like and not .php POST can't be used.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Your problem is that reg_globals is off - not that it should be a problem. There's security reasons why you should write code so it needn't be on.

To access any form variables passed to a PHP file (.php), just use the shorthand $_POST superglobal.

e.g.

HTML:

Code: Select all

&lt;form method="post" action="process.php" id="my_form"&gt;
&lt;input type="text" name="FOO" value="" /&gt;
&lt;/form&gt;
PHP:

Use the passed data by using the superglobal in the form:

Code: Select all

$_POST['FOO']
Weirdan | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
MarcusThe3rd
Forum Newbie
Posts: 3
Joined: Tue Nov 02, 2004 5:03 am
Location: Thailand
Contact:

Post by MarcusThe3rd »

Thanks for the replies.

What is the security issue with letting the reg_globals on?

Thankyou.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

MarcusThe3rd wrote: What is the security issue with letting the reg_globals on?
http://php.net/manual/en/security.globals.php
MarcusThe3rd
Forum Newbie
Posts: 3
Joined: Tue Nov 02, 2004 5:03 am
Location: Thailand
Contact:

Post by MarcusThe3rd »

Thanks

I was using PHP with reg_glod on earlier. So when I shifted to another machine with it off I was a bit in trouble. I was looking for this code to fetch values from forms. The thing is fine now. Thanks to all of you guys.

$VALUE1 = $_REQUEST['VALUE1']; //To capture data irrespect of send mathods

$VALUE1 = $_GET['VALUE1']; // for data send with GET method.

$VALUE1 = $_POST['VALUE1']; // for data send with POST method.

Hope this helps some one some day.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

well, there is a function that does this for you: [php_man]extract[/php_man]
Post Reply