Php token usage and verification example [test available] original, tokenfont
This example describes how to use and verify the php token. We will share this with you for your reference. The details are as follows:
I. Brief description of the token Function
Using token verification in PHP can effectively prevent unauthorized source data from being submitted for access and increase the security of data operations.
II. Implementation Method:
Front-end form:
<Form action = "do. php" method = "POST"> <? Php $ module = mt_rand (100000,999999);?> <Input type = "text" name = "sec_name" value = ""/> <input type = "hidden" name = "module" value = "<? Php echo $ module;?> "/> <Input type =" hidden "name =" timestamp "value =" <? Php echo time () ;?> "/> <Input type =" hidden "name =" token "value =" <? Php echo md5 ($ module. '#$ @ %! ^ * '. Time ();?> "/> </Form>
Do. php's token Verification Section in the background:
<? Php $ module =$ _ POST ['module']; $ timestamp =$ _ POST ['timestamp']; $ token = md5 ($ module. '#$ @ %! ^ * '. $ Timestamp); if ($ token! =_ _ POST ['Token']) {echo ('invalid data source'); exit () ;}$ sec_name =$ _ POST ['sec _ name']; // PHP Data Processing...?>