웹 프로그래밍에 대한 또 다른 질문이 있습니다.왜 내가 헤더를 이미 보냈는지 오류 메시지를받는 이유
로그인 스크립트를 프로그래밍했지만 로그인 할 때마다 헤더 정보를 이미 보냈다 고합니다.
이<?php
if($_GET['logout'] == 1) {
setcookie('authorized', 1, time()-3600);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login - photoAdminSite</title>
</head>
<style type="text/css">
body {
text-align: center;
font-family: helvetica;
}
#loginForm {
padding: 1em;
background: #e3e3e3;
width: 260px;
margin: 3em auto 0;
text-align: left;
}
</style>
<body>
<div id="loginForm">
<form method="post" action="confirm_login_credentials.php">
<h2>LOGIN</h2>
<p>Username: <input type="text" name="username" /></p>
<p>Password: <input type="password" name="password" /></p>
<p><input type="submit" value="Login" name="submit" /></p>
</form>
</div>
</body>
</html>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
require 'database.php';
$q = "SELECT id FROM users_photoadminsite WHERE user_name = '$username' AND password = '$password'";
$result = $mysqli->query($q) or die(mysqli_error());
if (mysqli_num_rows($result) == 1) {
setcookie('authorized', 1, 0);
header("Location: index.php");
} else {
header("Location: login.php");
}
?>
내가 유용한 답변 정말 행복 할 것 : 여기
는이 개 파일입니다.
아무도 사용자 이름을 선택하지 않기를 바랍니다 : ''; DROP TABLE users_photoadminsite; - ''! –
누군가가 이걸 어떻게 막아야합니까 '; DROP TABLE users_photoadminsite; - '?? – mikepenz
인증 체계가 안전하지 않습니다. 사용자 이름과 암호 해시 또는 일부 유형의 토큰을 저장하고 각 요청에 대해 유효성을 검사해야합니다. – mmattax