我的代码与我想要它做的相反,我试图创建一个简单的验证码,当我输入验证码上的值或字母和用户名/名称如果验证码字母是正确的我想要它打印hi $name,you types the correct captcha,如果输入的数据是错误的我只是想要打印nooo.我的问题是,当我输入正确的字母或数据时,它打印noo,当我把它留空而不输入任何数据时打印hi $name,you types the correct captcha
这是我的简单代码
<?php
session_start();
?>
<html>
<head>
<title> captcha test</title>
</head>
<body>
<?php
if(isset($_POST['submit'])){
if (isset($_SESSION['real'])) {
$real = $_SESSION['real'];
}
$guess = $_POST['captcha'];
$name = $_POST['name'];
$real = "";
if ($real == $guess){
echo "hi $name,you types the correct name";
}
else {
echo "Nooo";
}
} else {
?>
<form action= 'index.php' method='post'>
your name:<input type = 'text' name='name' />
<br />
<img src= 'image.php'> <input type='text' name='captcha' />
<br/>
<input type= 'submit' name='submit' value='go' />
</form>
<?php } ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |