下次一定要注意变量的大小写哦!
1.html
[code]
<!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=gb2312" />
<title>一元二次方程简单处理程序 fallingleaf@mail.youkuaiyun.com</title>
</head>
<!--BY fallingleaf@mail.youkuaiyun.com -->
<body>
<p>输入的格式为a(X*X)+bX+c:</p>
<form method="post" action="math.php">
<p>a=
<input type="text" maxlength=25 size=10 name="a" >
<br/>
b=
<input type="text" maxlength=25 size=10 name="b" >
<br/>
c=
<input type="text" maxlength=25 size=10 name="c" >
<br/>
<input type="submit" name="submit" value="提交" >
<br/>
</p>
</form>
<hr />
<span class="STYLE5">Copyleft © <a href="http://blog.youkuaiyun.com/fallingleaf">fallingleaf</a> 2007 All rights Reserved</span></div>
</body>
</html>
[/code]
math.php
[code]
<?php
//获取数值
$first = $_POST["a"];
$second = $_POST["b"];
$third = $_POST["c"];
//计算“待而塔”
$d=$second*$second-4*$first*$third;
//程序内容
if($d>0)
{
$x1=(-$second+sqrt($d))/2*$first;
$x2=(-$second-sqrt($d))/2*$first;
echo "$x1<br>";
echo "$x2";
}
elseif($d==0)
{
$x=(-$second+sqrt($d))/2*$first;
echo "$x";
}
else
{
echo "方程无实数根!";
}
?>
[/code]