首先,我想说这不是重复我在谷歌上尝试了所有内容,例如ob_functions和space not luck PHP应该这么简单,但它们没有愚蠢......
为什么我在脚本中启动cookie时出现此错误? 我已经评论了cookie开始我遇到了问题并希望有人可以帮忙修复它 我试过,现在放弃了浪费我的时间..
<!DOCTYPE html>
<?php
session_start();
?>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>Welcome To Spud Gaming</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
<link rel="stylesheet" href="assets/css/reset.css">
<link rel="stylesheet" href="assets/css/supersized.css?vvssv">
<link rel="stylesheet" href="assets/css/style.css?v12">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
require "../core/links.php";
if(isset($_SESSION['user'])) {
die;
}
if(isset($_COOKIE['user'])) {
die;
}
?>
<div class="page-container">
<br><br><br>
<h1>Sign In</h1>
<div style='color:black;'>
<?php
if((isset($_POST['username'])) && (isset($_POST['password']))) {
require "../core/data_connect.php";
$username = mysqli_real_escape_string($connection,$_POST['username']);
$password = mysqli_real_escape_string($connection,(sha1(md5($_POST['password']))));
if(($username) && ($password)){
$login_query_string = "SELECT * FROM spud_members WHERE ( username='$username' OR email = '$username') and password='$password'";
$login_query = mysqli_query($connection,$login_query_string);
$login_rows = mysqli_num_rows($login_query);
$login_array = mysqli_fetch_array($login_query);
$mid_login = $login_array['mid'];
$active_login = $login_array['active'];
//if we found a user with that information then sign them in
if($login_rows==1) {
//if the user as not been suspended then start there session
if($active_login==1) {
//if the user has not checked the remember me box
if($_POST['start_cookie_true_checked']!='on') {
$_SESSION['user']=$mid_login;
die;
} else if($_POST['start_cookie_true_checked']=='on') {
//otherwise if the remember me box has been checked then start a cookie instead
$date_of_expiry = time() + 60 ;
//THIS COOKIE HAS A ISSUE AND POPS UP THESE ERRORS!!!!!!!!!!!!!!!!!!!!!!!!!
setcookie("user", 'Mark', time()+3600);
die;
}
} else {
echo "<b>Account Suspended</b><br>
Your Account Has Been Suspended:<br>
This May Be Because You Have Broken Our Terms Of Use Guidelines<br><br>";
}
} else {
echo "<b>Invalid Username/Email Or Password</b><br>
The Username/Email Or Password That You Supplied Is Invalid<br>
Please Try Again or <a href=''> Reset Your Password</a>";
}
} else {
echo "<b>Blank Username/Email And Password</b><br>
You Haven't Entered A Username/Email And Password";
}
}
?>
</div>
<form action='' method='post'>
<input type='text' name='username' placeholder='Username Or Email' size='25' maxlength='30' /><br />
<input type='password' name='password' placeholder='Password' size='25' />
<input type='checkbox' name='start_cookie_true_checked'>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='index.php' /> <br><br>
<style>
a {
color:blue;
text-decoration:none;
}
</style>
<div>
<a href='signup'> Need An Account? </a> | <a href='forgot'> Forgot Password?</a>
</div>
<button type="submit">Sign In</button>
</form>
</div>
<!-- Javascript -->
<script src="assets/js/jquery-1.8.2.min.js"></script>
<script src="assets/js/supersized.3.2.7.min.js"></script>
<script src="assets/js/supersized-init.js?ddsddfd"></script>
<script src="assets/js/scripts.js"></script>
</body>
</html>
谢谢:)
答案 0 :(得分:0)
将HTML输出后移至session_start
函数。
<?php
session_start();
?>
<!DOCTYPE html>
答案 1 :(得分:0)
在开始向页面输出(从第一行代码开始)后,您无法尝试设置cookie(在响应标头中完成)。