Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP自动加载正在阻止POST_Php_Post_Composer Php_Autoloader - Fatal编程技术网

PHP自动加载正在阻止POST

PHP自动加载正在阻止POST,php,post,composer-php,autoloader,Php,Post,Composer Php,Autoloader,我开发了自己的PHP类,并使用composer管理它们之间的所有依赖关系。但是,每当我在任何PHP脚本上添加“供应商/自动加载”时,页面都不会发布。脚本无法识别或接收来自任何输入元素的post数据。下面的脚本“call.php”会自动发布,但不会发生任何事情 try { //------Page url $url = 'call'; //------Set page timeout parameters session_start(); if(

我开发了自己的PHP类,并使用composer管理它们之间的所有依赖关系。但是,每当我在任何PHP脚本上添加“供应商/自动加载”时,页面都不会发布。脚本无法识别或接收来自任何输入元素的post数据。下面的脚本“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();
}
试试看
{
//------页面url
$url='call';
//------设置页面超时参数
会话_start();
如果(isset($_会话['timeout'])&((time()-(int)$_会话['timeout'])>600)):
会话_destroy();
标题('位置:'。$url);
模具();
endif;
$\会话['timeout']=time();
//------添加所需的方法和类
需要目录名(_文件)。'/../includes/vendor/autoload.php';
//------获取加密的用户id和设备id
如果(isset($_-GET['id'])| | isset($_-GET['device'])):
//-----解密用户id和设备id
$decrypt=新解密();
$user_id=$decrypt->mc_decrypt($\u GET['id']);
$device_id=$decrypt->mc_decrypt($\u GET['device']);
//-----验证解密的数据
$check=新验证();
$c_id=$check->check_number($user_id,'n');
$c_device=$check->check_number($device_id,'y');
如果($c_id==1&&$c_设备==1)
{
//-----创建服务对象
$service=新服务($user\u id);
$status=$service->get_user_status();
//-----检查用户是否具有有效状态
如果($status!=100)
{   
标题('Location:logout?logout&message='.$status.#re101');
模具();
}
其他的
{
$user\u name=$decrypt->mc\u decrypt($service->get\u user\u name());
//-----检查以前的服务请求
$details=$service->get_service_call();
若有($详细信息)
{
$completed=false;
如果($details['b']=='pending')
{
$message='您的请求已被放置…';
$image='';
}
else if($details['b']=='processing')
{
$message='您的请求正在处理中…';
$image='';
}
其他的
{
$completed=true;
$service_id=$details['a'];
$message='您的请求已完成…';
$image='';
}   
$dated=$details['c'];
}
其他的
{
//-----创建新的服务请求
如果($service->create_service_call($device_id))
回显“创建的服务”;
$dated=日期('d-m-Y',time());
}
}
}
endif;
//-----完成后,通过接受用户评级和反馈关闭服务
如果(设置($_POST['submit'])和&!空($_POST['submit']):
$id=!空($_POST['service'])?$_POST['service']:'';
$rating=!空($_POST['rate'])?$_POST['rate']:'';
$feedback=!空($_POST['feed'])?$_POST['feed']:'';
$check=新验证();
$c_text=$check->check_text区域($feedback,'y');
$feed=新服务(0);
如果($rating==10 | |$rating==5 | |$rating==1)和&$c|U text==1)
{
如果($feedback='')
$feedback='nil';
如果($feed->提供服务\反馈($id,$rating,$feedback))
$give='谢谢您的反馈!';
其他的
$give='抱歉,无法发布您的反馈。';
}
其他的
$give='抱歉,出现了一个错误';
endif;
}
捕获(例外$e)
{
$log=新的杂项();
$log->handle_ex($url,$\u SESSION['account'],$e->getMessage(),$e->getFile(),$e->getLine());
标题('Location:'.SITE.'404.shtml');
模具();
}
通过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>

提交表格
$(文档).ready(函数(){
$(“#发送表单”)。单击(函数(){
var combinedFormData=$(“#form1”).serialize();
美元邮政(
“test.php”,
组合表单数据
).完成(功能(数据){
//警报(“已成功提交!”);
$(“#结果”).html(数据);
}).fail(函数(){
//警告(“提交表单时出错!”);
})
});
});
因此,所有代码都是在test.php文件中生成的,您可以检查是否使用php设置并返回它。您的表单必须具有id=“form1”,并且不需要

action=“page.php”method=“post”请将其从表单中删除 此外,按钮必须是

提交表单
如果你不明白,我可以为你的实现,如果你发送所有代码的形式和php的一部分

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