<?php
session_start();
error_reporting(0);
include("config.php");
?>
<?php echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>'; ?>
<html>
<head>
<title>MR stempagina</title>
</head>
<body>
<?php if( $_SESSION['user_info']['gestemd']>0){
header("Location: logout.php");
}
?>
<?php echo $_SESSION['user_info']['name'] ?>, u kunt hier stemmen.
<form action="stemmen.php" method="POST">
<p>Welke ouder wilt u als vertegenwoordiger van de ouders van de HBK afdeling in de medezeggenschapsraad?</p>
<input type="radio" name="kandidaat" value="piet"> piet<br>
<input type="radio" name="kandidaat" value="hein"> hein<br>
<p><input type="submit" name="stem" value="stem"></p>
<?php
$error = '';
if(isset($_POST['kandidaat'])){
echo $_POST['kandidaat'];
$_SESSION['user_info'] = $user;
//$query = " UPDATE ".$SETTINGS["USERS"]." SET gestemd = gestemd+1 WHERE id=".$_SESSION['id'];
//$query = " UPDATE ".$SETTINGS["USERS"]." SET gestemd = gestemd+1";
//$query = " UPDATE ".$SETTINGS["kandidaat"]." SET aantal = aantal+1";
//$query = " UPDATE ".$SETTINGS["USERS"]." SET gestemd = gestemd+1 WHERE id='{$_SESSION['id']}'";
$query = "UPDATE {$SETTINGS["USERS"]} SET gestemd = gestemd+1 WHERE id={$_SESSION['id']}";
mysql_query ($query, $connection ) or die ('request "Could not execute SQL query" '.$query . ': ' . mysql_error());
}
?>
</form>
</body>
</html>
当我使用时:
$query = " UPDATE ".$SETTINGS["USERS"]." SET gestemd = gestemd+1 WHERE id='{$_SESSION['id']}'";
table_column gestemd不增加。
当我使用相同的查询而没有它在哪里工作,但当然增加所有用户。
printR和echo用于调试。
谢谢你的帮助
最佳答案
我找到了问题的答案
$ query =“ UPDATE”。$ SETTINGS [“ USERS”]。“ SET gestemd = gestemd + 1 WHERE id = {$ _ SESSION ['user_info'] ['id']}”;
通过这种解决方案,它可以工作。