duanguoping2016 2018-11-22 12:38
浏览 99

无法加载源。 服务器响应500

I try to enter password when I open website, if the password true it will redirect me to the index.php, if the pass wrong it will let me try again. But why does it return internal error 500 ?

jquery-1.12.4.min.js:4 GET http://www.website.com/wp-content/themes/website/index.php 500 (Internal Server Error)

This is my php code (protect.php)

<?php
if( isset($_POST["password"])){
    if ($_POST["password"] == "1234"){

        header("Location:/wp-content/themes/website/index.php");
        exit();
}
else{
    echo "false";
  }
}

and this is my form with ajax (home.php). I think the problem here at the bottom in ajax ? :/

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" 
rel="stylesheet" id="bootstrap-css">
 <link href="<?php echo get_template_directory_uri() . 
'/css/websiteProtect.css'; ?>"   rel="stylesheet">

<link href="<?php echo get_template_directory_uri() . '/css/bootstrap.min.css'; ?>" rel="stylesheet">

<!------ Include the above in your HEAD tag ---------->

<!-- All the files that are required -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>

<script src="<?php echo get_template_directory_uri() . '/js/vendor/jquery-1.12.4.min.js'; ?>"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

<!-- Where all the magic happens -->
<!-- LOGIN FORM -->
<div class="text-center" style="padding:50px 0">
<div class="logo">Please enter password to browse site</div>
<!-- Main Form -->
<div class="login-form-1">
    <form id="protect-form"  name="protect-form"  class="protect-form text-left" method="post">
        <div class="login-form-main-message"></div>
        <div class="main-login-form">
            <div class="login-group">
                <div class="form-group">
                    <label for="password" class="sr-only">Password</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="password">
                </div>
                <div class="form-group login-group-checkbox">
                    <input type="checkbox" id="lg_remember" name="lg_remember">
                    <label for="lg_remember">remember</label>
                </div>
            </div>
            <button type="submit" class="login-button"><i class="fa fa-chevron-right"></i></button>
        </div>
    </form>
</div>
<!-- end:Main Form -->
</div>
 <script>
 /**
  * Created by Faisal_pc on 4/9/2016.
  */

 $(document).ready(function() {
     $('#protect-form').validate({
         rules: {
             password: {

                 required: true
             },

         },
         highlight: function(element) {
             $(element).closest('.form-group').removeClass('success').addClass('error');
         },
         success: function(element) {
             element.text('OK!').addClass('valid').closest('.form-group').removeClass('error').addClass('success');
         },

         submitHandler: function( form ) {

             $.ajax({
                 url : '/wp-content/themes/website/protect.php',
                 data : $('#protect-form').serialize(),
                 type: "POST",
                 success : function(data){
                     console.log(data)
                 }
             });
             return false;
         }
     });

 });

  • 写回答

1条回答 默认 最新

  • doubei5310 2018-11-22 13:02
    关注

    Try to use absolute way in header() function.

    Location: http://example.com/wp-content/themes/website/index.php

    or $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']

    official docs: http://php.net/manual/en/function.header.php

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。