会话值没有增加 [英] session values not increamented
本文介绍了会话值没有增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi2all
我尝试做的是当用户登录时我设置会话来存储他的尝试并增加它
$ b每个游戏登录尝试$ b
会话尝试仅保留值2,尽管用户仍然有超过2次尝试
我的代码是
hi2all
what i''m try to do is when user fall to login i set session to store his tries and increament it
for each faild login attempt
the session try hold only value 2 although the user still have more than 2 attempts
my code is
<?php
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
$_SESSION['try']=1;
@ $des=$_POST['user_pass'];
function encrypt_pkcs7($str, $key)
{
// derive 192-bit key using SHA-256
$key = substr(hash('sha256', $key, true), 0, 24);
$block = mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
$ciphertext = mcrypt_encrypt(MCRYPT_3DES, $key, $str, MCRYPT_MODE_ECB);
return base64_encode($ciphertext);
}
$password = encrypt_pkcs7('test', $des);
$user = $_POST['name'];
$connect = mysql_connect("localhost","root","");
mysql_select_db("register_form",$connect);
$query = "select id from users where name='$user' and password='$password'";
$res = mysql_query($query,$connect);
@$fetch = mysql_fetch_array($res);
if($fetch['id']){
require("html/index.html");
}
else{
if(isset($_SESSION['try']))
{
$_SESSION['try']=$_SESSION['try']+1;
$try=$_SESSION['try'];
}
else
{
$_SESSION['try']=1;
$try=$_SESSION['try'];
}
echo($_SESSION['try']);
require("html/re-signin.html");
$query1="insert into login_attempts (ip,attempts) values ('$ip','$try')";
$res1 = mysql_query($query1,$connect);
}
?>
推荐答案
ip =
ip =
_SERVER [' REMOTE_ADDR'];
_SERVER['REMOTE_ADDR'];
_SESSION [' try'] = 1;
@
_SESSION['try']=1; @
这篇关于会话值没有增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文