<?php session_start();
$chuoi="ABCDEFGHIJKLMNOPQRSTUVWYWabcdefghijklmnopqrstuvZ0123456789";
$i=0;
while($i<6)
{
$vitri=mt_rand(0,35);
$giatri=substr($chuoi,$vitri,5);
$i++;
}
session_register("kiemtra");
$_SESSION["kiemtra"]=$giatri;
?>
<?php require_once('random.php'); echo $_SESSION['kiemtra']; ?>
xử lý
<?php
$maBH = htmlentities($_POST['kiemtra'],ENT_QUOTES,'utf-8');
if($_SESSION['kiemtra']!=$maBH) echo "<script>alert('Bạn nhập mã bảo mật chưa chính xác');location.href='index.php?p=3'</script>" ;
?>
No comments: