|
|
|
|
复制本帖HTML代码
|
高亮:
今天贴
X 昨天贴
X 前天贴
X |
我达到在选中表单中输入数字然后确认后被Session记录或更新, 但我发现即便我没有点击另外一个表单的确认键, 其数据也同时增加.
不如, 我在表单1中输入3, 点击后两个session variable 会接受同样的值, 并显示同样结果.
请教问题的原因, 及如何解决?谢谢先;
程序如下:
<?php
session_start();
if( !session_is_registered("count1")){
session_register("count1");
$_SESSION[$count1]=0; }
if( !session_is_registered("count2")){
session_register("count2");
$_SESSION[$count2]=0; }
if(isset($_POST["ba"])){
echo "Button one is clicked!<br>";
$Q1 = $_POST['num1'];
$_SESSION[$count1]+=$Q1;
}
elseif(isset($_POST["bb"])){
echo "Button two is clicked!<br>";
$Q2 = $_POST['num2'];
$_SESSION[$count2]+=$Q2;
}
echo "Number1 is: $_SESSION[$count1]<br>
Number2 is:$_SESSION[$count2]<br><br>";
?>
number1:
<form method="post" action="cou.php">
<strong><font size="2">Number1:</font></strong>
<input type="text" name="num1" size="1" value="1">
<input type="submit" name="ba" value="add to one" >
</form>
number2:
<form method="post" action="cou.php">
<strong><font size="2">Number2:</font></strong>
<input type="text" name="num2" size="1" value="1">
<input type="submit" name="bb" value="add to two" >
</form>.
|
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法! |
|
|