Number Game
Checks weather the entered number is Lucky Number or not
Create a NumberGame.php file and add following code to it
<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Vowel or Constant</title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Number Game</h1>
<form name="form1" action="NumberGame.php" method="POST" >
<table >
<tr>
<td>Enter a Number between 40 to 50</td><td><input type="text" name="value1" maxlength="2" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Result</td><td><?php
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){ // this will not run for 1st time
$Value1=$_POST['value1']; // taking the value from textbox
$rand_number=rand(40,50 );//1st parameter is to check the starting range and 2nd is to check the End range of Number
if($Value1 == $rand_number ){//checking in both number are equal or not
echo "<h2>You Won!!!</h2>";
}else{
echo "$rand_number was the Lucky Numer..Hard luck!!<br /> Try again Later.";
}
}
?></td></font></tr>
</table
></form>
</div>
</body>
</html>"e
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Vowel or Constant</title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Number Game</h1>
<form name="form1" action="NumberGame.php" method="POST" >
<table >
<tr>
<td>Enter a Number between 40 to 50</td><td><input type="text" name="value1" maxlength="2" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Result</td><td><?php
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){ // this will not run for 1st time
$Value1=$_POST['value1']; // taking the value from textbox
$rand_number=rand(40,50 );//1st parameter is to check the starting range and 2nd is to check the End range of Number
if($Value1 == $rand_number ){//checking in both number are equal or not
echo "<h2>You Won!!!</h2>";
}else{
echo "$rand_number was the Lucky Numer..Hard luck!!<br /> Try again Later.";
}
}
?></td></font></tr>
</table
></form>
</div>
</body>
</html>"e