Undefine Variable ???

A

Anonymous

Guest
I just wonder why when i ran this script it says undefine variable

<html>
<head>
<title>Who Are You?</title>
</head>
<body>
<form action="you_are.php">

<?php
echo('<input type="text" name="person" value="' . $person . '"size="15">');
?>
<input type="submit" value="SUBMIT!" size="15">
</form>
</body>
</html>

Notice: Undefined variable: person in c:\inetpub\wwwroot\PHPCODE\who_are_you.php on line 9
 
My guess is that this is the register globals problem.
In all new versions of PHP the register global setting is default set to off (earlier it was on). That forces people to write a bit more secure scripts.

What this means when coding is that you need to use some supergloabls arrays when you want access certain variables.

If you send some variables from a form using the post or get method then to access those variables on the test.php page you need to use the $_POST or $_GET array. The same goes for getting variables from the url, but then you need to use the $_GET array.
All the different arrays are listed in the link above.

Example:
PHP:
<?php 
echo('<input type="text" name="person" value="' . $_POST['person'] . '"size="15">'); 
?>
 
Back
Top