服务器升级后PHP软件出现问题(HTTP头)

服务器升级后PHP软件出现问题(HTTP头),php,http,referer,Php,Http,Referer,我似乎遇到了一个问题,PHP函数在服务器升级后无法工作。上周,他们将服务器升级到PHP7.2,但在此之前,该软件运行良好。所以他们只是暂时将账户降级到7.0 请参阅以下代码: if($_POST['create_appointment']){ $customer_id = htmlspecialchars($_POST['customer'], ENT_QUOTES); $category_id = htmlspecialchars($_POST['category']

我似乎遇到了一个问题,PHP函数在服务器升级后无法工作。上周,他们将服务器升级到PHP7.2,但在此之前,该软件运行良好。所以他们只是暂时将账户降级到7.0

请参阅以下代码:

if($_POST['create_appointment']){ 
    $customer_id   = htmlspecialchars($_POST['customer'], ENT_QUOTES);
    $category_id   = htmlspecialchars($_POST['category'], ENT_QUOTES);
    $date       = htmlspecialchars($_POST['date'], ENT_QUOTES);
    $start_time = htmlspecialchars($_POST['start_time'], ENT_QUOTES);
    $end_time   = htmlspecialchars($_POST['end_time'], ENT_QUOTES);
    $booked_by  = htmlspecialchars($_POST['booked_by'], ENT_QUOTES);
    $booked_for =  post_array_to_explode($_POST['booked_for']);
    $notes      = htmlspecialchars($_POST['notes'], ENT_QUOTES);
    $session_id = htmlspecialchars($_POST['session_id'], ENT_QUOTES);
    $time       = date("Y-m-d H:i:s");
    $agent_id   = get_agent_from_session($session_id, 'id');

    $start_date = $date.' '.$start_time;
    $end_date = $date.' '.$end_time;

    $start_date = format_datetime_mysql($start_date);
    $end_date = format_datetime_mysql($end_date);

    $insert = $dbh->exec("INSERT INTO calendar(start_date, end_date, notes, category_id, customer_id, added_by, booked_by, booked_for, date_added) VALUES ('$start_date', '$end_date', '$notes', '$category_id', '$customer_id', '$agent_id', '$booked_by', '$booked_for', '$time')");
        if($insert){
            $notification_msg[] = array(type=>'alert-success', h4=>'Success!', msg=>'Appointment Created');
            push_browser_notify('New appointment booked', format_date($start_date).' - '.get_customer_json('business_name', $customer_id).' ('.get_customer_json('first_name', $customer_id).' '.get_customer_json('last_name', $customer_id).') ', '');     

            header('Location: ' . $_SERVER['HTTP_REFERER']);

        }else{
            $notification_msg[] = array(type=>'alert-warning', h4=>'Warning!', msg=>'Appointment NOT Created');
        }
}   
该软件位于子域上,其中主域附加了SSL证书。当我在子域上激活SSL时,似乎出现了HTTP引用问题。现在,它只会提出“未创建约会”的问题

有人能帮忙吗?如果这个问题没有意义,我很乐意重新回答这个问题

激活SSL时收到的错误消息为:

"(index):1 Failed to load https://agent.[domain].co.uk/ajax/livelead-new.php?session=0e9b832ead36586de0f56aba52079301641362a811363690298da1970b7ecb3d: No 
'Access-Control-Allow-Origin' header is present on the requested resource. Origin 
'http://agent.[domain].co.uk' is therefore not allowed access."

if($insert){
            $notification_msg[] = array(type=>'alert-success', h4=>'Success!', msg=>'Appointment Created');
            header('Location: ' . $_SERVER['HTTP_REFERER']);
        }else{
            $notification_msg[] = array(type=>'alert-warning', h4=>'Warning!', msg=>'Appointment NOT Created');
        }

我相信,如果您试图从其他服务器访问代码,您只需执行以下操作。我认为它不安全,但如果您将它放在处理请求的页面上,它应该会起作用:

<?php header('Access-Control-Allow-Origin: *'); ?>


您好-谢谢您的回答。我只是试了一下,不幸的是没有成功。我把它放在header.Dang、main header或该文件的header?main header-它作为include.allow放置。它不是来自不同的服务器。它与子域上的服务器相同。我会尝试将它放在处理请求的实际文件中。我听到了。我对Ajax/PHP也有同样的问题,尽管它在同一个域上。把它添加到我的文件中,效果很好。我正在使用Codeigniter,并将其直接放在类声明上方。请看以下答案: