3个回答
2013-08-21
展开全部
其实这个是php最简单的表单处理应用吧?你还要什么功能?
<form method="post" action="">
n1:<input type="text" name="n1"> +
n2:<input type="text" name="n2">
<input type="submit" name="sub" value="计算">
</form>
<?php
if(isset($_POST['sub'])){
$sub=$_POST['n1']+$_POST['n2'];
echo $_POST['n1'].'+'.$_POST['n2'].'='.$sub;
}
?>
www.zh30.com
<form method="post" action="">
n1:<input type="text" name="n1"> +
n2:<input type="text" name="n2">
<input type="submit" name="sub" value="计算">
</form>
<?php
if(isset($_POST['sub'])){
$sub=$_POST['n1']+$_POST['n2'];
echo $_POST['n1'].'+'.$_POST['n2'].'='.$sub;
}
?>
www.zh30.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-21
展开全部
<?
if($_SERVER['REQUEST_METHOD'] == "POST"){
switch (intval($_POST['js'])) {
case 1:
$daan = intval($_POST['A']) + intval($_POST['B']);
break;
}
}
?>
<!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>PHP加法运算</title>
</head>
<body>
<form method="post" action="">
<input name="A" type="text" style="WIDTH: 20px" value="<?echo $_POST['A'];?>"/>
<input type="hidden" name="js" value="1" <?if($_POST['js']==1) echo "checked='checked'"?>/>+
<input name="B" type="text" style="WIDTH: 20px" value="<?echo $_POST['B'];?>"/>
<input type="submit" name="Submit" style="WIDTH: 20px" value="=" /><?echo $daan;?>
</form>
</body>
</html>
if($_SERVER['REQUEST_METHOD'] == "POST"){
switch (intval($_POST['js'])) {
case 1:
$daan = intval($_POST['A']) + intval($_POST['B']);
break;
}
}
?>
<!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>PHP加法运算</title>
</head>
<body>
<form method="post" action="">
<input name="A" type="text" style="WIDTH: 20px" value="<?echo $_POST['A'];?>"/>
<input type="hidden" name="js" value="1" <?if($_POST['js']==1) echo "checked='checked'"?>/>+
<input name="B" type="text" style="WIDTH: 20px" value="<?echo $_POST['B'];?>"/>
<input type="submit" name="Submit" style="WIDTH: 20px" value="=" /><?echo $daan;?>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-21
展开全部
接收2个POST值,然后相加即可
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询