嗨,我很難理解會話如何工作。我試圖寫一個程序,將多次請求輸入一個數字,每一個數字輸入編程時間打印出:商店變量會話php
- 這個數字
- 所有號碼的總和進入
- 在多少次的計數我提交
這是我到目前爲止的代碼:
<?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
變量,因此每次我提交時它輸出數字的總和進入
FYI:'$ CNT = 0; '然後'isset($ cnt)'將是** false **! – undone