Page 1 of 1

Methord="POST" doesn't work

Posted: Tue Nov 02, 2004 5:19 am
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]

Posted: Tue Nov 02, 2004 6:12 am
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.

...

Posted: Tue Nov 02, 2004 6:14 am
by Calimero
Just to note,

if your page has extension .htm or like and not .php POST can't be used.

Posted: Tue Nov 02, 2004 6:33 am
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]

Posted: Thu Nov 04, 2004 11:17 pm
by MarcusThe3rd
Thanks for the replies.

What is the security issue with letting the reg_globals on?

Thankyou.

Posted: Thu Nov 04, 2004 11:26 pm
by Weirdan
MarcusThe3rd wrote: What is the security issue with letting the reg_globals on?
http://php.net/manual/en/security.globals.php

Posted: Wed Nov 10, 2004 8:08 am
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.

Posted: Wed Nov 10, 2004 9:29 am
by timvw
well, there is a function that does this for you: [php_man]extract[/php_man]