hello all,
I have installed the windows version of PHP to learn how to code php. Since I've installed it, if I have page that has the $submit variable, and I dont use .php4, it get an error saying the variable wasnt declared. But if i use .php4 I dont get the error. I'm just doing some tutorials. Heres the code that im using.
-----------------------------------------
<?
if (!$submit)
{
// if $submit doesn't exist, it implies that the form
// has not yet been submitted
// so display the first page
?>
<html>
<head>
<style type="text/css">
td {font-family: Arial;}
</style>
</head>
<body>
<font face="Arial" size="+2">
The Amazing Fortune Cookie Generator
</font>
<form method="GET" action="cookie.php4">
<table cellspacing="5" cellpadding="5" border="0">
<tr>
<td align="center">
Pick a day
</td>
<td align="right">
<select name="day">
<option value="Monday">Monday
<option value="Tuesday">Tuesday
<option value="Wednesday">Wednesday
<option value="Thursday">Thursday
<option value="Friday">Friday
<option value="Saturday">Saturday
<option value="Sunday">Sunday
</select>
</td>
</tr>
<tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="Hit me!">
</td>
</tr>
</table>
</form>
</body>
</html>
<?
}
else
{
// if $submit does exist, the form has been submitted
// so process it with switch()
// the decision variable here is the day chosen by the user
switch ($day)
{
// first case
case "Monday":
$fortune = "Never make anything simple and efficient when a way can be
found to make it complex and wonderful.";
break;
// second case
case "Tuesday":
$fortune = "Life is a game of bridge -- and you've just been
finessed.";
break;
case "Wednesday":
$fortune = "What sane person could live in this world and not be
crazy?";
break;
case "Thursday":
$fortune = "Don't get mad, get interest.";
break;
case "Friday":
$fortune = "Just go with the flow control, roll with the crunches,
and, when you get a prompt, type like hell.";
break;
// if none of them match...
default:
$fortune = "Sorry, closed on the weekend";
break;
}
?>
<html>
<head>
<basefont face="Arial">
</head>
<body>
Here is your fortune for <? echo $day; ?>:
<br>
<b><? echo $fortune; ?></b>
</body>
</html>
<?
}
?>
-------------------------------------
Is there anything wrong w/ this code? Its a tutorial on Developer Shed for PHP
Thank you ,
shorty
I have installed the windows version of PHP to learn how to code php. Since I've installed it, if I have page that has the $submit variable, and I dont use .php4, it get an error saying the variable wasnt declared. But if i use .php4 I dont get the error. I'm just doing some tutorials. Heres the code that im using.
-----------------------------------------
<?
if (!$submit)
{
// if $submit doesn't exist, it implies that the form
// has not yet been submitted
// so display the first page
?>
<html>
<head>
<style type="text/css">
td {font-family: Arial;}
</style>
</head>
<body>
<font face="Arial" size="+2">
The Amazing Fortune Cookie Generator
</font>
<form method="GET" action="cookie.php4">
<table cellspacing="5" cellpadding="5" border="0">
<tr>
<td align="center">
Pick a day
</td>
<td align="right">
<select name="day">
<option value="Monday">Monday
<option value="Tuesday">Tuesday
<option value="Wednesday">Wednesday
<option value="Thursday">Thursday
<option value="Friday">Friday
<option value="Saturday">Saturday
<option value="Sunday">Sunday
</select>
</td>
</tr>
<tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="Hit me!">
</td>
</tr>
</table>
</form>
</body>
</html>
<?
}
else
{
// if $submit does exist, the form has been submitted
// so process it with switch()
// the decision variable here is the day chosen by the user
switch ($day)
{
// first case
case "Monday":
$fortune = "Never make anything simple and efficient when a way can be
found to make it complex and wonderful.";
break;
// second case
case "Tuesday":
$fortune = "Life is a game of bridge -- and you've just been
finessed.";
break;
case "Wednesday":
$fortune = "What sane person could live in this world and not be
crazy?";
break;
case "Thursday":
$fortune = "Don't get mad, get interest.";
break;
case "Friday":
$fortune = "Just go with the flow control, roll with the crunches,
and, when you get a prompt, type like hell.";
break;
// if none of them match...
default:
$fortune = "Sorry, closed on the weekend";
break;
}
?>
<html>
<head>
<basefont face="Arial">
</head>
<body>
Here is your fortune for <? echo $day; ?>:
<br>
<b><? echo $fortune; ?></b>
</body>
</html>
<?
}
?>
-------------------------------------
Is there anything wrong w/ this code? Its a tutorial on Developer Shed for PHP
Thank you ,
shorty