私のコードは、私がやりたいこととは逆のことをしています。キャプチャに値または文字を入力すると、単純なキャプチャを作成しようとしています。キャプチャ文字が正しい場合は、ユーザー名/名前を入力しますhi $name,you types the correct captcha
。入力したデータが間違っています。印刷したいだけです。nooo
問題は、正しい文字またはデータを入力すると印刷されず、データを入力せずに空白のままにすると印刷されることです。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>
私は何を間違っていますか?