前端form.php

来源:1-7 PHP验证码制作之通过SESSION存储验证信息

下雨看世界

2016-02-27 13:13

        <html>  
                <head>
                        <meta charset = 'utf-8' />
                        <title>确认验证码</title>
                </head>
                <body>
                        <form method = "POST" action =./form.php>
                                <p>验证码图片:<img border = "1" src = "./identifyCode.php?r=<?php echo rand();?>" width ="100" height= "30" /></p>      
                                <p>请输入图片上的内容:<input type = "text" name = "authcode" value = "" /> </p>
                                <p><input type = "submit"  value = "提交" style = "padding:6px 20px;"></p>
                        </form>
                </body>
        </html>

前端代码显示正常,为什么加入了下面的代码,前端表单代码就显示不出来了?

<?php
    header("Content-type:text/html;charset=utf-8");
    if(isset($_REQUEST['authcode'])){
        session_start();

        if (strtolower($_REQUEST['authcode']) == $_SESSION['authcode']) {
            echo '<font color="#0000CC">输入正确</font>';
        }else{
            echo '<font color="#CC0000"><b>输入错误</b></font>';
        }
    }
    exit();
?>

写回答 关注

2回答

  • 请叫我大帅哥
    2016-03-16 12:00:43

    我的也是这样,问题解决了,谢谢哥们的指教。


  • weibo_慕桂英6548011
    2016-02-28 17:03:47

            <html>  
                    <head>
                            <meta charset = 'utf-8' />
                            <title>确认验证码</title>
                    </head>
                    <body>
                            <form method = "POST" action =./form.php>
                                    <p>验证码图片:<img border = "1" src = "./captcha_cn4.php?r=<?php echo rand();?>" width ="100" height= "30" /></p>      
                                    <p>请输入图片上的内容:<input type = "text" name = "authcode" value = "" /> </p>
                                    <p><input type = "submit"  value = "提交" style = "padding:6px 20px;"></p>
                            </form>
                    </body>
            </html>


    <?php
        header("Content-type:text/html;charset=utf-8");
        if(isset($_REQUEST['authcode'])){
            session_start();

            if (strtolower($_REQUEST['authcode']) == $_SESSION['authcode']) {
                echo '<font color="#0000CC">输入正确</font>';
            }else{
                echo '<font color="#CC0000"><b>输入错误</b></font>';
            }
        }
        exit();
    ?>

    把标出来部分换成我的地址,显示是正常的。

    清下缓存,或换个浏览器试试


PHP实现验证码制作

各种形态验证码核心原理与实现技巧,讲解实现过程中的技术难点

37916 学习 · 321 问题

查看课程

相似问题