我想让用户通过提交按钮接受/拒绝事件的请求。信息被循环显示(用户名,位置,接受,拒绝)。接受/拒绝提交按钮循环与PHP
现在2个用户正在显示;用户1和用户2(当前用于测试)。无论如何,我试图让正确的用户名使用正确的用户名。目前,无论我接受或拒绝哪个用户,都会显示用户2。我试图根据隐藏的输入设置用户标识的值,但它不能正常工作。
这是我的代码。
for($i=0;$i<count($userExplode)-1;$i++){
$user = mysql_query("select userid,username from users where userid = ".$userExplode[$i]." ");
$user = mysql_fetch_array($user);
$userLoc = mysql_query("select userLocation from userinfo where userid = ".$userExplode[$i]." ");
$location = mysql_fetch_array($userLoc);
$locationExplode = explode("~",$location['userLocation']);
//the displayed output is working correctly so I know it's setting $user['userid'] properly
echo '<form method="post"><table><tr><td><a href="profile.php?userid=' . $user['userid'] . '">' . $user['username'] . '</a></td>
<td>' . $locationExplode[0] . ', ' . $locationExplode[1] . '</td>
<td><input type="hidden" name="userReq" value='.$user['userid'].'></td>
<td><input type="submit" name="accept" value="Accept Request" ></td>
<td><input type="submit" name="decline" value="Decline Request" ></td></tr>';
}
echo '</table></form>';
}
if(isset($_POST['accept'])){
echo $_POST['userReq']; //displays user 2 even if I click user 1
}
if(isset($_POST['decline'])){
echo $_POST['userReq']; //also displays user 2 even if i click user 1
}
}
你应该使用'$ _GET'而不是'$ _POST' – Gaurav 2012-02-11 19:59:03
感谢您的提示!使用$ _GET来安全吗?我想我只需再次检查其他页面,只有在事件的创建者是访问该页面的页面时才允许。 – user1104854 2012-02-11 20:02:42
如果您安全使用它是安全的。只有管理员才可以提出这些要求。 – Richard 2012-02-11 20:04:21