I want to use the security token as hidden input field in my comment form for security purpose. I know if there is only one form in my webpage, I can do some thing like that
$token = sha1(uniqid(rand(), TRUE));
$_SESSION['token'] = $token;
I can use this token in my form
<form action="comment.php" method="post">
<input type="hidden" name="token" value="<?php echo $token; ?>" />
<input type="text" name="comment_body" value="" />
</form>
and on the receiving end, I can do that
if ($_POST['token'] == $_SESSION['token']){
/* Valid Token */
}
But I have about 10 forms on a single page So How I can generate multiple tokens and How to handle them on receiving end. And What If a user open multiple pages?