I read about CSFR, it is not clear why this code does not work:
<? session_start(); $_SESSION["sid"] = md5(time() . rand(0, 10000)); ?> <!DOCTYPE html> <html> <head> <title>FORM</title> </head> <body> <div id="wrap"> <form action="" method="POST"> <input type="hidden" id="sid" name="sid" value="<?= $_SESSION["sid"]; ?>"> <textarea cols="50" name="msg" rows="10"></textarea> <br> <input type="submit" name="sub" value="Send"> </form> </div> </body> <script type="text/javascript"> </script> <? if(isset($_POST["sub"])) { if(isset($_POST["sid"]) && $_POST["sid"]==$_SESSION["sid"]{ $_SESSION["sid"]="" ; echo "SUCCESS!"; } else { echo "ERROR!"; } } ?> </html> gives ERROR, it is clear that the page reloads .. but then how to do it right? the name "sid" = "token" . Never mind