我的php文件/代码在本地可以正常工作,但是当您将其上传到服务器时,它会返回
警告:无法修改标头信息-已在/ home / techover / public_html / abira / Capstone2 /中发送(由/home/techover/public_html/abira/api/apiOnly.php:1开始的输出)发送的标头信息第27行的login.php
login.php
<?php
require '../api/dbcon.php';
require '../api/apiOnly.php';
if(session_id() == '' || !isset($_SESSION)) {
// session isn't started
session_start();
}
//FACULTY - USER LOGIN
if(isset($_POST['login'])){
//do query here
$stmt = $conn->prepare('SELECT username, campus, designation FROM accounts where username = ? AND password = ? ');
$stmt->bind_param('ss', $u, $p);
$u=$_POST['username'];
$p=md5($_POST['password']);
$stmt->execute();
$stmt->bind_result($username,$campus, $designation);
if($stmt->fetch()>0){
$_SESSION['usr_fullname'] = $username;
$_SESSION['usr_type'] = $designation;
$_SESSION['usr_campus'] = $campus;
if($_SESSION['usr_type']=='admin'){
header('location: home.php');
exit();
}else if($_SESSION['usr_type']=='director'){
header('location: director-index.php');
exit();
}
}else{
$faculty = json_decode($api->authenticate_student($_POST['username'],$_POST['password']),true);
if(!empty($faculty[0]['usr_fullname'])){
$_SESSION['usr_fullname'] = $faculty[0]['usr_fullname'];
$_SESSION['usr_type'] = 'faculty';
header('location: faculty-index.php');
}else{
echo "<script type='text/javascript'>
alert ('Username and Password unmatched!');
window.location.href='login.php';</script>";
}
}
$stmt->close();
$conn->close();
}
?>
dbcon.php
<?php
if(session_id() == '' || !isset($_SESSION)) {
// session isn't started
session_start();
}
error_reporting(E_ALL & E_STRICT);
ini_set('display_errors', '1');
ini_set('log_errors', '0');
ini_set('error_log', './');
$dbhost = 'localhost';
$dbuser = '------';
$dbpass = '-----';
$dbtable = "------";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbtable);
if(!$conn ){
die('Could not connect: ' . mysqli_error());
}
?>
抱歉,此开发中的新内容
答案 0 :(得分:-1)
在php标记后的文件开始处启动会话
if(session_id() == '' || !isset($_SESSION)) {
// session isn't started
session_start();
}