【问题标题】:403 Forbidden on form submission403 禁止提交表单
【发布时间】:2010-12-03 00:57:19
【问题描述】:

我有一个返回 403 禁止的 URL,原因不明。我在 .htaccess 中禁用了 mod_security,将文件修改为 0777。网址是

http://www.veepiz.com/afrostar.php?app=help&func=addvideo

当您提交表单时会发生任何想法?

这里是代码

function PublicAddVideo()
    {
    if (isset($_POST['submit_addvideo']))
        {
        require_once("class.phpmailer.php");     
        //send email tobirthday person
        $subject="New AfroStar Video Suggested";
        $msg = "Dear Jordah,\n".
              "Youtube video: ".$_POST['youtubesle']."\n Star Name: ".$_POST['starnamesle']."\n Country: ".$_POST['countrysle']."\n IP Address: ".getRealIpAddr();
        $mail = new PHPMailer();
        $mail->IsSMTP();                                      // set mailer to use SMTP
        $mail->Host = "localhost";  // specify main and backup server
        $mail->SMTPAuth = true;     // turn on SMTP authentication
        $mail->Username = "support@veepiz.com";  // SMTP username
        $mail->Password = "********"; // SMTP password
        $mail->From = "support@veepiz.com";
        $mail->FromName = "Veepiz";
        $mail->AddAddress('jordahz@hotmail.com',"Jordah Ferguson");
        $mail->AddReplyTo("support@veepiz.com", "Veepiz");
        $mail->WordWrap = 50;                                 // set word wrap to 50 characters
        $mail->IsHTML(true);                                  // set email format to HTML
        $mail->Subject = $subject;
        $mail->Body    = nl2br($msg);
        $mail->AltBody = $msg;
        if(!$mail->Send())
            {
            }
        ?>
        <div style='color:green;'>Admins at veepiz.com have been notified of your request and will update afrostar application accordingly.<div align='center' style='padding:10px'>&nbsp;&nbsp;<a  href='afrostar.php' onclick="return getPage('afrostar_class.php',{});" class='btn'>Back to AfroStars</a></div></div>
        <?php             
        } else
        {
        $this->DisplayHeader("Add African Video");    
        ?>
        <script language="javascript">
          var checkHelpVars=function ()
            {
            err='';
            if ($('#starnamesle').val().length==0) err+="Please type in the name of the star";
            if ($('#countrysle').val().length==0) err+="\nName of the country missing";
            if ($('#youtubesle').val().length==0) err+="\nYoutube url missing";
            var url=$('#youtubesle').val();
            var matches = url.match(/^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=[\w-]+)(?:\S+)?$/);
            if (matches) {
                } else {
                err +="\nInvalid Youtube Url";
                }                
            if (err.length>0)
                {
                alert(err);
                return false;    
                }    
            <?php 
            if (isloggedin())
                {
                echo "return postPage('afrostar_class.php?app=help&func=addvideo',{starnamesle:$('#starnamesle').val(),countrysle:$('#countrysle').val(),youtubesle:encodeURI($('#youtubesle').val()),submit_addvideo:1});";    
                } else
                {
                echo "return true;";    
                }                     
            ?>
            }  
        </script>
        <form id='helpform' method="POST" action="http://www.veepiz.com/afrostar.php?app=help&amp;func=addvideo">
        <table cellpadding="2" cellspacing="3">
            <tr>
                <td><b>Africa Artist Name:</b></td>
                <td><input id='starnamesle' type="text" style='' name='starnamesle' style='-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;width:450px'/></td>
            </tr>
            <tr>
                <td><b>Country:</b></td>
                <td><input id='countrysle' type="text" style='' name='countrysle' style='-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;width:450'/></td>
            </tr>                
            <tr>
                <td><b>Youtube link:</b></td>
                <td><input id='youtubesle' type="text" style='' name='countrysle' style='-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;width:450'/><br/>Example:<small style='font-size:8pt;color:#666666'>http://www.youtube.com/watch?v=vJyftjMOd2w</small></td>
            </tr>                
            <tr>
                <td colspan="2" align="center"><input type="submit" class="btn" onclick="return checkHelpVars();" name='submit_addvideo' value="Finish"></td>
            </tr>                
        </table>
        </form>

        <?php    
        $this->DisplayFooter();
        }   
    }

【问题讨论】:

    标签: php http-status-code-403


    【解决方案1】:

    检查您的帖子数据,如果它包含任何 url,则有可能在服务器中被阻止。

    您应该替换您提交的网址中的某些字符,然后您需要在发布时转换回其原始形式。

    【讨论】:

    • 谢谢.. 真的很有帮助:)
    • 我该怎么做?假设我在表单中有一个文本框,我如何替换文本框数据以及在什么时候将其转换回来,然后再保存到数据库?
    【解决方案2】:

    我的解决方案:

    听起来您没有对之前传递的 URL 进行 urlencoding 您将其嵌入到您要传递到的脚本的 URL 中。

    【讨论】:

      【解决方案3】:

      这里有人说要将权限更改为 644

      http://www.daniweb.com/forums/thread21777.html

      【讨论】:

        【解决方案4】:

        我意识到我为 countrysle 定义了两次名称....所以我将其更改为这个,现在它可以[在表单中]

                <tr>
                    <td><b>Country:</b></td>
                    <td><input id='countrysle' type="text"  name='countrysle' style='-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;width:250px'/></td>
                </tr>                
                <tr>
                    <td><b>Youtube link:</b></td>
                    <td><input id='youtubesle' type="text" name='youtubesle' style='-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;width:250px'/><br/>Example:<small style='font-size:8pt;color:#666666'>http://www.youtube.com/watch?v=vJyftjMOd2w</small></td>
                </tr> 
        

        【讨论】:

          【解决方案5】:

          您需要在您遇到问题的字段的输入标签中添加type= "text" 属性。还可以尝试在表单属性中使用method= "post" 而不是get,这也会导致此问题。

          【讨论】:

            【解决方案6】:
            1. 制作一个.htaccess文件
            2. 将此行SecFilterEngine Off放入.htaccess文件中
            3. 将此 htaccess 文件保存在 root 文件夹中

            【讨论】:

              【解决方案7】:

              http://www.linuxforums.org/forum/servers/34130-you-dont-have-permission-access-server-solved.html

              阅读该链接的最后一条评论:

              “刚刚谷歌搜索了我的问题并找到了 这个线程。大部分都在我的 头,但我创建了一个新文件夹,把 我的“禁止”文件在那里,它 解决了这个问题。谢谢!”

              WTF!

              【讨论】:

              • 我明白这一点,但如果没有其他帮助,值得一试。
              • 该页面已不存在。不确定这个修复是什么。
              【解决方案8】:

              令人难以置信的是,我发现如果我将帖子字符串从“空白表单网页”更改为“空白网页”,即省略技术词“表单”,表单将发布文本而服务器不会抛出“禁止”留言!!!

              【讨论】:

                猜你喜欢
                • 2017-06-11
                • 2021-09-25
                • 1970-01-01
                • 2022-09-23
                • 2012-05-20
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多