PHP自动加载正在阻止帖子



我开发了自己的PHP类,并使用作曲家来管理它们之间的所有依赖关系。但是,每当我在任何PHP脚本的顶部都包含"供应商/自动加载"时,该页面都不会发布。脚本均未识别或接收到任何输入元素的帖子数据。以下脚本" call.php"帖子帖子本身,什么也不会发生。

try
{
    //------Page url
    $url = 'call';
    //------Set page timeout parameters 
    session_start();    
    if(isset($_SESSION['timeout'])  && ((time() - (int)$_SESSION['timeout']) > 600)):
        session_destroy();
        header('Location: '.$url);
        die();  
    endif; 
    $_SESSION['timeout'] = time();
    //------Add required methods and classes
    require dirname(__FILE__).'/../includes/vendor/autoload.php';
    //------Get encrypted user id & device id
    if(isset($_GET['id']) || isset($_GET['device'])):
        //-----Decrypt user id and device id
        $decrypt   = new decryption();
        $user_id   = $decrypt->mc_decrypt($_GET['id']);
        $device_id = $decrypt->mc_decrypt($_GET['device']);
        //-----Validate decrypted data          
        $check     = new validation();
        $c_id      = $check->check_number($user_id    ,'n');
        $c_device  = $check->check_number($device_id  ,'y');
        if($c_id==1 && $c_device==1)
        {
            //-----Create a service object
            $service = new service($user_id);
            $status  = $service->get_user_status();
            //-----Check if the user has a valid status
            if($status != 100)
            {   
                header('Location: logout?logout&message='.$status.'#re101');
                die();
            }
            else
            {
                $user_name = $decrypt->mc_decrypt($service->get_user_name());
                //-----Check for previous service requests
                $details   = $service->get_service_call();
                if($details)
                {
                    $completed = false;
                    if($details['b'] == 'pending' )
                    {
                        $message = '<h2>Your request has been placed...</h2>';
                        $image   = '<h2><img src="images/call_in.png alt="" height="100px" width="300px"/></h2>';
                    }
                    else if($details['b'] == 'processing' )
                    {
                        $message = '<h2>Your request is under process...</h2>'; 
                        $image   = '<h2><img src="images/call_up.png" alt="" height="100px" width="300px"/></h2>';
                    }
                    else
                    {
                        $completed = true;
                        $service_id = $details['a'];
                        $message = '<h2>Your request has been fulfilled...</h2>';
                        $image   = '<h2><img src="images/call_out.png" alt="" height="100px" width="300px"/></h2>';
                    }   
                    $dated = $details['c']; 
                }
                else
                {
                    //-----Create a new service request
                    if($service->create_service_call($device_id))
                        echo "Service created";
                    $dated = date('d-m-Y', time()); 
                }
            }
        }
    endif;      
    //-----Once fulfilled, close the service by accepting user rating and feedback
    if(isset($_POST['submit'])&&!empty($_POST['submit'])):
        $id       = !empty($_POST['service'])?$_POST['service']:'';
        $rating   = !empty($_POST['rate'])?$_POST['rate']:'';
        $feedback = !empty($_POST['feed'])?$_POST['feed']:'';
        $check   = new validation();
        $c_text  = $check->check_textarea($feedback, 'y');
        $feed    = new service(0);
        if(($rating == 10 || $rating == 5 || $rating == 1) && $c_text == 1)
        {
            if($feedback == '')
                $feedback = 'nil';
            if ($feed->give_service_feedback($id, $rating, $feedback))
                $give = 'Thank you for your feedback!';
            else    
                $give = 'Sorry, could not post your feedback.';
        }
        else
            $give = 'Sorry, there was an error.';
    endif;
}
catch(Exception $e) 
{
    $log = new misc();
    $log->handle_ex($url, $_SESSION['account'], $e->getMessage(), $e->getFile(), $e->getLine());
    header('Location: '.SITE.'404.shtml');
    die();
}

通过ajax

发布
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- button to send form post -->        
<button id="sendforms">Submit forms</button>
        <div id="result"><!-- result of post page goes here --></div>
        <script type="text/javascript">
            $(document).ready(function () {
              $("#sendforms").click(function() {
                       var combinedFormData = $("#form1").serialize();
                     $.post(
                            "test.php",
                            combinedFormData
                     ).done(function(data) {
                            //alert("Successfully submitted!");
                            $("#result").html(data);
                     }).fail(function () {
                              //alert("Error submitting forms!");
                     })
              });
            });
        </script>

因此,所有代码帖子均在 test.php 文件中进行,您可以检查是否使用PHP设置,并且还将其返回您的表单必须具有 id =" form1" ,不需要

action =" page.php" method =" post"请从您的表格中删除此 此外,按钮必须为

<button id="sendforms">Submit forms</button>

如果您不明白,如果将所有代码发送给您的表单和PHP Part

,我可以为您的实施

相关内容

  • 没有找到相关文章

最新更新