亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

驗證碼存在并有效但在聯系表上未激活

驗證碼存在并有效但在聯系表上未激活

PHP
楊__羊羊 2022-12-23 14:41:22
我正在嘗試將 IconCaptcha ( https://github.com/fabianwennink/IconCaptcha-Plugin-jQuery-PHP#installation ) 添加到聯系表單。我設法在網頁上成功實現了它。但是每當我點擊提交按鈕(其他字段填寫良好)時,表格就會被發送。即使我打錯了驗證碼……或者根本沒有驗證碼。這是 contact.php 頁面代碼:<?php    session_start();    require('IconCaptcha-PHP/src/captcha-session.class.php');    require('IconCaptcha-PHP/src/captcha.class.php');    IconCaptcha::setIconsFolderPath('../assets/icons/');    IconCaptcha::setIconNoiseEnabled(true);    if(!empty($_POST)) {        if(IconCaptcha::validateSubmission($_POST)) {            $captchaMessage = 'Le message a bien été envoyé!';        } else {            $captchaMessage = json_decode(IconCaptcha::getErrorMessage())->error;        }    }?><!doctype html><!--  * IconCaptcha Plugin: v2.5.0* Copyright ? 2017, Fabian Wennink (https://www.fabianwennink.nl)* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php--><html><head><!--FORMAT--><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge">  <!--[if lt IE 9]>    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>  <![endif]--><!--STYLES--><link href="css/styles.css" rel="stylesheet" type="text/css"><link href="css/bootstrap-4.3.1.css" rel="stylesheet" type="text/css"><!-- IconCaptcha stylesheet --><link href="IconCaptcha-PHP/assets/css/icon-captcha.min.css" rel="stylesheet" type="text/css"><script src="http://use.edgefonts.net/montserrat:n4:default.js" type="text/javascript"></script><!--SCRIPTS BOOTSTRAP--><script src="js/jquery-3.3.1.min.js"></script><script src="js/popper.min.js"></script><script src="js/bootstrap-4.3.1.js"></script><body><section id="contact" class="section-orange">    <div class="container-fluid" justify-content="center" style="width: 90%">                            
查看完整描述

1 回答

?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

我與圖標驗證碼的創建者有聯系。他幫了我很多,實際上比我預期的要多。


第一個錯誤,我把一部分 PHP 驗證代碼頁放在聯系表上:


    if(!empty($_POST)) {

        if(IconCaptcha::validateSubmission($_POST)) {

            $captchaMessage = 'Le message a bien été envoyé!';

        } else {

            $captchaMessage = json_decode(IconCaptcha::getErrorMessage())->error;

        }

    }


它應該從 contact.php 到 envoiformulaire.php。


在那之后,他幫助我掌握了麻木的 PHP 技能......


在聯系頁面的頂部,應添加以下代碼:


<?php

    session_start();


    require('IconCaptcha-PHP/src/captcha-session.class.php');

    require('IconCaptcha-PHP/src/captcha.class.php');


    IconCaptcha::setIconsFolderPath('../assets/icons/');

    IconCaptcha::setIconNoiseEnabled(true);

?>


并在 envoiformulaire.php 中添加此代碼 (ADD):


<?php

    session_start(); // ADD THIS


    header('Content-Type: text/html; charset=utf-8');


    require('IconCaptcha-PHP/src/captcha-session.class.php'); // ADD THIS

    require('IconCaptcha-PHP/src/captcha.class.php'); // ADD THIS


    IconCaptcha::setIconsFolderPath('../assets/icons/'); // ADD THIS

    IconCaptcha::setIconNoiseEnabled(true); // ADD THIS


    if(isset($_POST['email'])) {


        $email_to = "[email protected]";

        $email_subject = "Nouveau message web";


        function died($error) {

            echo "Oups! Une ou plusieurs erreurs se trouvent dans votre formulaire.<br>";

            echo $error."<br /><br />";

            die();

        }



        // validation expected data exists

        if(!isset($_POST['first_name']) ||

            !isset($_POST['last_name']) ||

            !isset($_POST['email']) ||

            !isset($_POST['telephone']) ||

            !isset($_POST['comments'])) {

            died('Oups! Un probl?¨me est survenu avec votre formulaire.');

        }


        // ADD THIS

        if(!IconCaptcha::validateSubmission($_POST)) {

            died('ADD YOUR ERROR MESSAGE HERE');

        }


        ...


現在,效果很好,謝謝 Fabian!


我希望這篇文章將來能對某人有所幫助。


弗雷德里克。


查看完整回答
反對 回復 2022-12-23
  • 1 回答
  • 0 關注
  • 93 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號