Index09b1.php

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>留言页面</title>

</head>

    <body>

<form action="" method="post">

验证码:<input type="text" size="10" name="check">

<img src="p_w_picpath.php">

<input type="submit" name="ok" value="提交">

</form>

    </body>

</html>

<?php

session_start();   //启动session

if (isset($_POST['ok']))

{

         $checkstr=$_SESSION['string'];     //使用$SESSION变量获取p_w_picpath.php页面上的验证码

         $str=$_POST['check'];       //用户输入的字符串

         if (strcasecmp($str, $checkstr)==0)   //不区分大小写进行比较

             echo "<script>alert('验证码输入正确!');</script>";

             else

             echo "<script>alert('输入错误!');</script>";

}

 ?>