嗨,我无法理解会话是如何工作的。我正在尝试编写一个程序,该程序将重复请求输入一个数字,并且每次输入该数字时,程序都会打印出来:
- 那个号码
- 输入的所有数字的总和
- 我提交的次数
到目前为止,这是我的代码:
<?php
session_start();
if(isset($_session['count']))
{
$_session['count'] = $count;
}else{
$_session['count'] = 0;
}
?>
<html>
<head>
<title>number</Title>
<style>
</style>
<body>
<form action = "numbers.php" method = "post">
Numbers: <input type "text" name = "number" size = "6"/>
<input type = "submit" value = "submit" name = "submit"/>
<p>
</form>
</body>
</head>
</Html>
<?php
if(isset($_POST["submit"]))
{
$number = $_POST['number'];
If (is_numeric($number))
{
$count = $_session['count'] + $number;
print "Last number entered: ".$number;
print "<br>Total internal numbers: ".$count;
}
}
?>
我试图存储我的$count
变量,所以每次我提交它都会输出输入数字的总和