Write a PHP script to accept an Indian currency and then convert it in dollar or pounds (radio buttons) according to user’s preference. (use concept of self processing form)||EasyCoding45
In this Tutorial we are going to learn how we can Write a PHP script to accept an Indian currency and then convert it in dollar or pounds (radio buttons) according to user’s preference. (by using concept of self processing form)
Program::--
<html>
<head>
<title>Currency Conversion</title>
<body>
<?php
if($_SERVER['REQUEST_METHOD']=='GET')
{
?>
<form action="<?php echo$_SERVER['PHP_SELF']?>" method="POST">
Enter Amount in rupees :<input type=text name=t1><br>
<input type=radio name=r1 value=1>Convert into Dollar<br>
<input type=radio name=r1 value=2>Convert into Pounds<br>
<input type=submit value=Convert><br>
</form>
<?php
}
else if($_SERVER['REQUEST_METHOD']=='POST')
{
$Amt=$_POST['t1'];
$op=$_POST['r1'];
switch($op)
{
case 1:
echo "Conversion from Rupees to dollars is :";
$cm=$Amt/73.84;
echo "$cm dollars";
break;
case 2:
echo "Conversion from Rupees to Pounds is :";
$km=$Amt/99.31;
echo "$km pounds";
break;
}
}
?>
</body>
</html>
Comments
Post a Comment