enter code here
我创建了一个基本的投票系统。该数据库具有3列col1,col2,col3。
像“提交按钮_1”上的php代码的col1值将更新为+1。
因此,我单击了数据库中更新的button_1值。但是,当我刷新浏览器时,无需单击button_1,数据库col1的值就会增加。
<?php
include "vote.des.php";
$con = mysqli_connect("localhost","root","","voting");
if(isset($_POST['ele'])){
header("Loction: vote.php");
$vote_ele = "update votes set ele = ele + 1";
$run = mysqli_query($con,$vote_ele);
}
if(isset($_POST['comp'])){
header("Loction: vote.php");
$vote_comp = "update votes set comp = comp + 1";
$run = mysqli_query($con,$vote_comp);
}
if(isset($_POST['phy'])){
header("Loction: vote.php");
$vote_phy = "update votes set phy = phy + 1";
$run = mysqli_query($con,$vote_phy);
}
mysqli_close($con);
?>
输出必须是: 当我单击按钮时,值应该被更新。当我不单击按钮时,该值不应更新。在刷新浏览器时,该值不应更新。