Home >Backend Development >PHP Tutorial > 一段关于验证码的判断的vbs代码,请好手转成php代码

一段关于验证码的判断的vbs代码,请好手转成php代码

WBOY
WBOYOriginal
2016-06-13 13:10:101044browse

一段关于验证码的判断的vbs代码,请高手转成php代码

VBScript code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
 "" Then 
      Dim checkCode,sessionCode
      checkCode = Trim(Request.QueryString("checkCode"))
      sessionCode=Session("verifycode")
      
      '下面这两句是用来转换注册码全部为大写,可以方便用户输入
      checkCode=UCase(checkCode)
      sessionCode=UCase(sessionCode)


      If checkCode = sessionCode Then 
              Response.Redirect("http://www.hzynh.cn")''这里输入下载地址,验证成功后就可以跳转到下载地址
      Else 
             Response.Write("<script>alert('验证码错误,请重新输入');</script>") 
      End If 
End If 
%>




------解决方案--------------------
PHP code

<?php if (!empty($_REQUEST['submit']))
{
    $checkCode = strtoupper(trim($_REQUEST['checkCode']));
    $sessionCode = strtoupper($_SESSION['verifycode']);
    
    if ($checkCode==$sessionCode)
        echo "<script>window.location.href='http://www.hzynh.cn';";
    else
        echo "<script>alert('验证码错误,请重新输入');</script>";
}
?>
<br><font color="#e78608">------解决方案--------------------</font><br><?php <br />if(isset($_POST['submit']))<br>{<br>	$checkCode =Trim($_POST['checkCode']);<br>	session_start();<br>	$sessionCode=$_SESSION['verifycode'];<br>	session_destroy();<br>	$checkCode=UCase($checkCode);<br>   $sessionCode=UCase($sessionCode);<br>	if($checkCode == $sessionCode)<br>	{<br>		Header("Location:http://www.hzynh.cn");<br>	}<br>	else<br>	{<br>		echo "<script>alert('验证码错误,请重新输入');</script>";<br>	}<br>}<br>?><br><br>
<br><font color="#e78608">------解决方案--------------------</font><br>如果你读取的是 php 的session,那么你没有启用 session<br>缺少 session_start();<br><br>如果你试图读取 asp 的 session,那么对不起,你这样是读不到的 <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn