PHP PEAR을 배우고 다음 코드를 테스트하고 있습니다. 그러나 로그인 할 때 다음 오류가 발생합니다.PEAR를 사용하는 중 오류가 발생했습니다.
아무도 코드에 무엇이 잘못되었는지 말해 줄 수 있습니까?
++++++++++++++++
경고 :에도 session_regenerate_id() [function.session-중생-ID] : 세션 ID를 다시 생성 할 수 없습니다 - 이미 C에서 전송 헤더를 : \ xampp \ php \ PEAR \ Auth.php on line 830
경고 : 헤더 정보 - 이미 보낸 헤더 (C : \ xampp \ htdocs \ php5adv \ Ch04 \ login.php : 50에서 시작된 출력)를 수정할 수 없습니다. C : \ XAMPP의 \ PHP는 \ 배 \ Auth.php 라인에 858
++++++++++++++++
<?php # Script 4.3 - login.php
/* This page uses PEAR Auth to control access.
* This assumes a database called "auth",
* accessible to a MySQL user of "[email protected]"
* with a password of "password".
* Table definition:
CREATE TABLE auth (
username VARCHAR(50) default '' NOT NULL,
password VARCHAR(32) default '' NOT NULL,
PRIMARY KEY (username),
KEY (password)
)
* MD5() is used to encrypt the passwords.
*/
// Need the PEAR class:
require_once "Auth.php";
// Function for showing a login form:
function show_login_form() {
echo '<form method="post" action="login.php">
<p>Username <input type="text" name="username" /></p>
<p>Password <input type="password" name="password" /></p>
<input type="submit" value="Login" />
</form><br />
';
} // End of show_login_form() function.
// Connect to the database:
$options = array('dsn' => 'mysql://username:[email protected]/auth');
// Create the Auth object:
$auth = new Auth('DB', $options, 'show_login_form');
// Add a new user:
$auth->addUser('me', 'mypass');
?><!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Restricted Page</title>
</head>
<body>
<?php
// Start the authorization:
$auth->start();
// Confirm authorization:
if ($auth->checkAuth()) {
echo '<p>You are logged in and can read this. How cool is that?</p>';
} else { // Unauthorized.
echo '<p>You must be logged in to access this page.</p>';
}
?>
<a href="logout.php>Logout</a>
</body>
</html>
@shin : 코드 형식을 지정하기 위해 질문을 편집했습니다. 이는 각 코드 줄 앞에 4 칸을 추가한다는 것을 의미합니다. php 태그 앞에 공백이 있었고, formating 할 때 그것들을 유지했습니다. 당신이 사용하고있는 코드에 실제로 포함되어 있습니까? 그렇지 않다면 두 번째 편집하여 나중에 제거하고 싶을 수도 있습니다 :-( –
감사합니다 PascalMARTIN, 방금 편집했습니다. php. – shin
@shin : 편집 해 주셔서 감사합니다. 공백 :-( –