Are you familiar with using this type of methods to avoid duplication? Seems like there is a short delay when I submit the form, making the $_SESSION not match up with the current uniqid();, making it useless.Yes , token validation is a preferred security measure.
Are you familiar with using this type of methods to avoid duplication? Seems like there is a short delay when I submit the form, making the $_SESSION not match up with the current uniqid();, making it useless.
I'm still not able to post the comment, as the two values end up being different when i submit the form.You must be registered for see links
<?php
$formToken = uniqid();
$_SESSION['form-token'] = $formToken;
if($_POST['post-token'] == $_SESSION['form-token']){
$comment = strip_tags(filter($_POST['comment']));
if(empty($comment)){
} else {
if (isset($_POST['post_comment']) && isset($_SESSION['user'])) {
dbquery("INSERT INTO support_replies (user_id, report_id, message, time_sent) VALUES ('".$_SESSION['user']['id']."', '".filter((int)$_GET['ticketid'])."', '".filter($comment)."', '".time()."');") or die(mysqli_error());
$error_message = 'Thanks for your reply!<br /><br />';
echo $error_message;
}
}
}
echo $_SESSION['form-token'].'<br>';
echo $_POST['post-token'];
?>
<br><br>
<div id="toggle-textfield" class="toggle-textfield">
<form action="" method="post">
<input type="hidden" name="post-token" value="<?php echo $formToken; ?>">
<textarea name="comment" maxlength="500"></textarea><br />
<input type="submit" name="post_comment" value="Kommentér" />
</form>