无法使用验证码?

Can't get CAPTCHA's to work?

我最近考虑使用 CAPTCHAs,因为我有一个联系表格,我想将其添加到其中。

但是,每个验证码似乎都显示相同的问题,即一旦我实施了验证码,您应该在 上回答验证码的文本区域有 PHP文本区域本身的代码.

如果有人能指导我完成 link 一些可行的验证码,将不胜感激!


这是我目前所拥有的:

形式:

<div class="contactform">
        <form class="form" action="mail.php" method="POST">

            <div class="namebox">
            <p class="name">
                <label for="name">Name</label>
                <input type="text" name="name" id="name">
            </p>
            </div>

            <div class="emailbox">
            <p class="email">
                <label for="email">Email</label>
                <input type="text" name="email" id="email">
            </p>
            </div>

            <div class="titlebox">
            <p class="title">
                <label for="title">Title</label>
                <input type="text" name="title" id="title">
            </p>
            </div>
            <br>

            <div class="descriptionbox">
            <p class="description">
                <label for="description">Description</label>
                <textarea name="description"> </textarea>
            </p>
            </div>

            <br>

            <p class="submit">
                <input type="submit" value="Submit">
            </p>

        </form>
        </div>

PHP:

<?php 
$name = $_POST['name'];
$title = $_POST['title'];
$email = $_POST['email'];
$description = $_POST['description'];
$formcontent ="From: $name \n Message: $description";
$recipient = "email@email.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you. Your message will be reviewed as soon as possible!";
?>

你知道验证码的工作原理吗?
让我给你解释一下:
CAPTCHA 保护系统的工作原理是生成一个随机字符串,将其写入图像,然后将字符串存储在会话中或通过其他一些方法。然后在提交表单时对其进行检查。
THIS 文章是一个有价值的来源,查看它,它将指导您创建安全的验证码。

@Fred-ii- So I do realise this is a beyond late answer, but I felt bad for not coming back here. However, I have sorted it out. While this code in specific is not currently in use, I contacted another friend that has quite a bunch of PHP knowledge, mostly just to check and he said the same thing, that the extensions are whats causing it. Cheers for your answers and replies though! :)

评论回答以结束问题:

我认为可能发生的情况是,您的 HTML 表单没有包含 .php 扩展名,这就是为什么您在其中显示 "PHP code",而不是解析。

  • 如果您的文件是 .htm.html,请将其重命名为 .php