Thursday, September 12, 2013

Number Game

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

Thursday, September 5, 2013

Check Vowel or Constant

Vowel or Constant

check the weather the entered Character is Vowel or Constant

Create a  VowelConstant.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>Check It is Vowel or Constant</h1>
<form name="form1" action="VowelConstant.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" maxlength="1" /></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 
if($Value1 =="a" || $Value1 =="e" || $Value1 =="i" ||$Value1 =="o" || $Value1 =="u" || $Value1 =="A" || $Value1 =="E" || $Value1 =="I" ||$Value1 =="O" || $Value1 =="U"  ){//checking in both lower and upper case
echo "$Value1 is a Vowel!!";
}else{
echo "$Value1 is a Constant!!";
}
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Temperature Converter

Temperature converter 

change the Temperature  from Celsius to Fahrenheit and from Fahrenheit to Celsius  

Create a  temperature.php  file and add following code to it 

<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Temperature </title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Temperature</h1>
<form name="form1" action="temperature.php" method="POST" >
<table >
<tr><td>Enter Temperature</td><td><input type="text" name="value1" /></td></tr>
<tr><td>Celsius to Fahrenheit  </td><td><input type="radio" name="temp" value="celTofar" /> 
</td>
</tr>
<tr><td>Fahrenheit to Celsius </td><td><input type="radio" name="temp" value="farTocel" /> </td>
</tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Changed Value  is :</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){
$Value1=$_POST['value1'];
$Source=$_POST['temp'];
if($Source=="farTocel"){
echo  $Value1 * 9/5 +32 ."`C";
}else{
echo  ($Value1-32) * 5/9 ."`F";
}
//echo $Value1." Total " .$Value2 .$operation;
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Check Even Odd in php

Even od Odd

Check the given number is even or odd

Create a  EvenOdd.php  file and add following code to it 


<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Even or Odd </title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Check It is Even or Odd</h1>
<form name="form1" action="EvenOdd.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><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 
if($Value1 % 2==0){
echo "$Value1 is a Even Number!!";
}else{
echo "$Value1 is a Odd Number!!";
}
}
?></td></font></tr>
</table
</form>
</div>
</body>
</html>

Currency Converter

PHP assignment 

Create a currency Converter 

Create a  converter.php  file and add following code to it


<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>converter </title>
</head>
<body>
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Converter</h1>
<form name="form1" action="converter.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" /></td></tr>
<tr><td>Source currency </td><td><select name="Source">  
<option value="Euro">Euro</option>
<option value="Dollar">Dollar </option>
<option value="Rupees">Rupees </option>
</select></td>
</tr>
<tr><td>Destination currency </td><td><select name="Destination">  
<option value="Euro">Euro</option>
<option value="Dollar">Dollar </option>
<option value="Rupees">Rupees </option>
</select></td>
</tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Changed Value  is :</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){
$Value1=$_POST['value1'];
$Source=$_POST['Source'];
$Destination=$_POST['Destination'];
if($Source== $Destination){
echo "Please Select Diff Choice!!";
}elseif($Source=="Dollar" && $Destination=="Rupees" ){
echo $Value1 /68;
}elseif($Source=="Rupees" && $Destination=="Dollar" ){
echo $Value1 *68;
}elseif($Source=="Euro" && $Destination=="Rupees" ){
echo $Value1 *0.011;
}elseif($Source=="Rupees" && $Destination=="Euro" ){
echo $Value1 /0.011;
}elseif($Source=="Dollar" && $Destination=="Euro" ){
echo $Value1 *0.76;
}elseif($Source=="Euro" && $Destination=="Dollar" ){
echo $Value1 /0.76;
}
//echo $Value1." Total " .$Value2 .$operation;
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Calculator in php

PHP assingment

Create Simple arithmetic calculator with basic validation.


First create a calc.php file  and then add the following code to it