Where should i put this code~ help~
Posted: Tue May 20, 2008 12:25 am
I am just started to learn HTML+PHP... I am using the book called "PHP/MySQL Programming For The Absolute Beginner"
The codes is something like this...
Program 1:
<html>
<head>
<title>What's your name?</title>
</head>
<body>
<h1>What's your name?</h1>
<h3>Writing a form for user input</h3>
<form method = "post"
action = "hiUser.php">
Please type your name:
<input type = "text"
name = "userName"
value = "">
<br>
<input type = "submit">
</form>
</body>
</html>
Program 2:
<html>
<head>
<title>Hi User</title>
</head>
<body>
<h1>Hi User</h1>
<h3>PHP program that receives a value from "whatsName"</h3>
<?
print "<h3>Hi there, $userName!</h3>";
?>
</body>
</html>
I have tried to test run this code... for the program 1(.html) everything works fine.. but for the program 2(.php) it cant get the result from program 1...
There are some statement shown in the book..
IN THE REAL WORLD
Some PHP servers have turned off the ability to automatically create a variable from a form. You might be able to convince your server administrator to turn register_globals on in the PHP.INI file. If not, here's a workaround: If your form has a field called userName, add this code to the beginning of the program that needs the value of that field:
$userName = $_REQUEST["userName"];
* I have tried to turn on the register_globals or using $userName = $_REQUEST["userName"]; code but still same problem occur.. and i am not sure where to put this code... i guess its in the program 2 but where??
THANKS FOR THE ADVANCE!!!
The codes is something like this...
Program 1:
<html>
<head>
<title>What's your name?</title>
</head>
<body>
<h1>What's your name?</h1>
<h3>Writing a form for user input</h3>
<form method = "post"
action = "hiUser.php">
Please type your name:
<input type = "text"
name = "userName"
value = "">
<br>
<input type = "submit">
</form>
</body>
</html>
Program 2:
<html>
<head>
<title>Hi User</title>
</head>
<body>
<h1>Hi User</h1>
<h3>PHP program that receives a value from "whatsName"</h3>
<?
print "<h3>Hi there, $userName!</h3>";
?>
</body>
</html>
I have tried to test run this code... for the program 1(.html) everything works fine.. but for the program 2(.php) it cant get the result from program 1...
There are some statement shown in the book..
IN THE REAL WORLD
Some PHP servers have turned off the ability to automatically create a variable from a form. You might be able to convince your server administrator to turn register_globals on in the PHP.INI file. If not, here's a workaround: If your form has a field called userName, add this code to the beginning of the program that needs the value of that field:
$userName = $_REQUEST["userName"];
* I have tried to turn on the register_globals or using $userName = $_REQUEST["userName"]; code but still same problem occur.. and i am not sure where to put this code... i guess its in the program 2 but where??
THANKS FOR THE ADVANCE!!!