I finished with the installation of apache server(2.0), php4, mysql(4.0) and started doing some exercises. I followed the steps mentioned in the website http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html for installation. I could able to run some simple programs and see the results in the screen. When I run the following program, I have an issue. I could able to enter the number and when I press enter it blank the field and stops there. I think the parameter 'guess' is not getting passed to the 'if' statement.
<?php
$num_to_guess = 42;
$message = "";
if ( ! isset( $guess ) )
{
$message = "Welcome to the guessing machine!";
}
elseif ( $guess > $num_to_guess )
{
$message = "$guess is too big! Try a smaller number";
}
elseif ( $guess < $num_to_guess )
{
$message = "$guess is too small! Try a larger number";
}
else // must be equivalent
{
$message = "Well done!";
}
?>
<html>
<head>
<title>Listing 9.10 A PHP number guessing script</title>
</head>
<body>
<h1>
<?php print $message ?>
</h1>
<form action="<?php print $PHP_SELF?>" method="POST">
Type your guess here: <input type="text" name="guess">
</form>
</body>
</html>
I tested another program with the same kind of parameter passing. In this example I have
<FORM ACTION="welcome.php" METHOD=POST>
First Name: <INPUT TYPE=TEXT NAME="firstname"><BR>
Last Name: <INPUT TYPE=TEXT NAME="lastname">
<INPUT TYPE=SUBMIT VALUE="GO">
</FORM>
welcome.php:
<?php
echo( "Welcome to our Web site,
$firstname $lastname!" );
?>
When I click the button it opens the next screen But, I don't see the values(first name,last name) entered from the first screen. What could be the reason ?
Thanks in advance.
Kris