因此,我有一個網站使用註冊/登錄系統爲用戶創建一個帳戶。我使用MAMP在本地主機上完美工作。但是,我將我的網站和數據庫上傳到實時服務器,並且出現錯誤。以下是註冊頁面。當用戶登記,就應該帶他們到他們的帳戶頁面,但是在註冊頁面刷新,他們得到以下錯誤:活網站上的PHP錯誤,在本地主機上正常工作
警告:在session_start():無法發送會話cookie - 標題已經發出(輸出開始於/srv/disk4/2113278/www/lucasclarke.co.nf/webTechFinal/connections.php:16)位於第7行的/srv/disk4/2113278/www/lucasclarke.co.nf/webTechFinal/Register.php
警告:在session_start():無法發送會話緩存限制器 - 在已經發送了頭(輸出開始/srv/disk4/2113278/www/lucasclarke.co.nf/webTechFinal/connections.php:16)/ SRV /磁盤4/2113278/WWW/lucasclarke.co.nf/webTechFinal/Register.php線路7
警告:不能更改頭信息 - 頭已經發出(輸出開始/ SRV /磁盤4/2113278/WWW/lucasclarke。 co.nf/webTechFinal/connections.php:16)在/srv/disk4/2113278/www/lucasclarke.co.nf/webTechFinal/Register.php第16行
注意,信息用戶寄存器DOES正確地進入我的數據庫,但該網站沒有像我在本地主機上那樣工作。有什麼想法嗎?提前致謝。
<?php require 'connections.php'; ?>
<?php
if(isset($_POST['register'])) {
session_start();
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$email = $_POST['email'];
$pw = $_POST['password'];
$sql = $con->query("INSERT INTO user (Fname, Lname, Email, Password)Values('{$fname}', '{$lname}', '{$email}', '{$pw}')");
header('Location: Login.php');
}
?>
<!------------------------------------------------------------------>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Notekeep</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<div class="container">
<h1 class="title">Register<img src="logo.png" id="logo"></h1>
<form action="" method="post" name="registerform" id="registerform">
<div>
<input name="first_name" type="text" required="required" id="first_name" placeholder="First Name">
</div>
<div>
<input name="last_name" type="text" required="required" id="last_name" placeholder="Last Name">
</div>
<div>
<input name="email" type="email" required="required" id="email" placeholder="Email">
</div>
<div>
<input name="password" type="password" required="required" id="password" placeholder="Password">
</div>
<div>
<!-- <input name="password2" type="password" required="required" id="password2" placeholder="Re-Enter Password"> -->
</div>
<div>
<input name="register" type="submit" class="button" id="register" value="Register">
</div>
</form>
<a class="link" href="Login.php">Login</a>
</div>
</body>
</html>
檢查connections.php的第16行 – Musa
'<?php require'connections.php'後面的空格; ''不能在那裏。服務器將該空間計數爲輸出到引發錯誤的瀏覽器。刪除'?>'和<?php' – Rasclatt
你也應該在'header('Location:Login.php');'後面添加'exit;'。 – Rasclatt