当我单击第一个按钮时,变量增加一个,但是当我单击第二个按钮时,第一个变量变为0。如何解决?还有其他方法可以做到吗? 代码:
<!DOCTYPE html>
<html>
<head>
<title>some Texte</title>
</head>
<body>
<?php
session_start();
if (!isset($_POST['add'])) {
$_SESSION['num'] = 0;
}
if (!isset($_POST['add1'])) {
$_SESSION['num1'] = 0;
}
?>
<form method='post'>
<input name='add' type="submit" value='Vote!'>
<h3><em>Number of Votes:<?php echo $_SESSION['num']++ ?> </em></h3>
<input name='add1' type="submit" value='Vote!'>
<h3><em>Number of Votes:<?php echo $_SESSION['num1']++ ?> </em></h3>
</form>
</body>
</html>