Web Hosting Talk







View Full Version : passing variables: php.ini?


dendros
01-21-2003, 11:20 AM
Hi to all! as a newbie, got a problem with the newest version PHP. I installed as cgi on apache server (also newest version)

I have basically 2 files:File1 is the Form. Gets the variable Data_del as input in form, and as action it opens file2.php

The variable from the form, is not showing in my script. Variable is been recognized by php, as shown by phpinfo() function I included in the script., but is not taken by the script.

Does this have to do with the new security configuration of php (Global and registered variables?)

What do I have to change in PHP.INI file, in order to pass variable from script to script on same sesssion?

As example: the mini script:

File1.htm with form

<form method="POST" action="File2.php">
<p><input type="text" name="Data_del" size="50"></p>
<p>Data to delete:</p>
<p><input type="submit" value="Delete values"></p>
</form>



file2.php

<?php
echo "Deleted data: '$Data_del'";
phpinfo();
?>


My OUTPUT is => Deleted data: "

Thanks for the help

Dendros

Rich2k
01-21-2003, 11:21 AM
You don't, just write your script so it is php 4.1.0+ compliant

$_POST['Data_del']

dendros
01-21-2003, 02:37 PM
ups....
I suppose I got the wrong starting book... might have to learn directly from php manual before using any other book

thanks for your observation! and help.

dendros

Rich2k
01-21-2003, 06:35 PM
You can use the old method by editing php.ini and changing 'register_globals' to on, but as good practice you should secure your scripts by writing them assuming that register_globals is off (as it is by default in php 4.2.0 onwards).

Of course if your server is pre php 4.1.0 then you have to use the old method.

Quickfoot
01-21-2003, 08:08 PM
Not entirely correct, you can not use super globals in pre 4.1.0 but you can use $HTTP_GET_VARS and $HTTP_POST_VARS which exist in pre PHP 4.1.0 and post PHP 4.1.0, the catch is these arrays are not automatically global.

You should use super globals if you can but if you have to write code for an older version of PHP but you want it to work with newer versions of PHP as well you do not need register globals on.