Archive for November, 2010

php function using include

November 16th, 2010

IIC University of Technology Evening Class (B205)
filename: func.php
formfunc.php

formfunc.php

<?php
include("func.php");
if(isset($_GET['btncal'])){
echo "My Add is". add($_GET['txtx'],$_GET['txty']);
echo "<br>";
echo "My Sub is". sub($_GET['txtx'],$_GET['txty']);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<form method="get">
X:<input  type="text" name="txtx" />
Y:<input  type="text" name="txty" />
<input type="submit" name="btncal" />
</form>
<body>
</body>
</html>

func.php

<?php
function add($x,$y){
$total = $x + $y;
return $total;
}
function sub($x,$y){
$sub = $x - $y;
return $sub;
}
?>

Homework1

November 9th, 2010

IIC University of Technology Evening Class (B205)
filename: homework1.php

<?php
$x = $_GET['txtx'];
$send = $_GET['btnsend'];
if(isset($send)){
if(!$x){
$error_x = "Please input X";
}
else{
switch($x){
case 1:
echo "X is Number 1";
break;
case 2:
echo "X is Number 2";
break;
case 3:
echo "X is Number 3";
break;
case 4:
echo "X is Number 4";
break;
case 5:
echo "X is Number 5";
break;
case 6:
echo "X is Number 6";
break;
case 7:
echo "X is Number 7";
break;
case 8:
echo "X is Number 8";
break;
case 9:
echo "X is Number 9";
break;
case 10:
echo "X is Number 10";
break;
default:
echo "Value is not around 1 to 10";
}
}

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Control Statement</title>
</head>
<body>
<form action="#" method="get">
<label for="x">x:</label><input type="text" name="txtx" /><?php echo $error_x; ?><br />
<input type="submit" name="btnsend" /> | <input type="reset" />
</form>
</body>
</html>
Facebook Auto Publish Powered By : XYZScripts.com