【发布时间】:2014-06-03 02:38:40
【问题描述】:
我真的是 PHP 新手,我正在尝试使用这个问题中提到的简单验证码 Numeric Captcha for PHP
我要做的是将$_SESSION['captcha'] 传递到我的当前页面,以便它可以与我刚刚输入的应该通过“表单”传递的输入进行比较。
这是我的代码:
<?php
if(isset($_POST['captcha'] ,$_SESSION['captcha'])) {
if ($_POST['captcha'] == $_SESSION['captcha'])
echo 'YES, YOU DID IT';
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>captcha test</title>
</head>
<body>
<form name="input" action="index.php" method="POST">
<img src="captcha.php">
Enter the code above: <input type="text" name="captcha">
<input type="submit" value="Submit">
</form>
</body>
</html>
这样做的正确方法是什么?如何在当前代码中实现验证码?
【问题讨论】:
-
那你为什么不复制完整的例子呢?
-
@mario:我复制的,第一部分代码在captcha.php中