Я нахожусь в процессе разработки сайта под управлением FileMaker с использованием PHP API. Я использовал книгу «FileMaker API для PHP 13», которая до сих пор была чрезвычайно полезной.
В любом случае, я пытаюсь создать страницу входа для доступа к базе данных после Урока 15 из книги. Когда я нажимаю на кнопку входа, я получаю следующую ошибку:
Предупреждение: невозможно изменить информацию заголовка - заголовки уже отправлены (вывод начался с /htdocs/fm_api_for_php/Advanced/Lesson15/Login.php:22) в /htdocs/fm_api_for_php/Advanced/Lesson15/Login.php on линия 56
Это код со страницы Login.php:
<?php
# You have the start the session on the login page.
# The session_start() method MUST be before the html tag.
# Always set the $_SESSION login value to 0 on the login page to protect the other pages by default.
session_start();
$_SESSION['login']=0;
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<!--
The purpose of this file is to show how to perform a log in procedure to protect web pages from unauthorized access.
The method uses 2 pages. Start at Loging.php. If login is sucessful the user is redirected to LoginSuccess.php.
LoginSuccess.php is the starting web page for your protected solution.
If users try to open a protected page without logging in they will be re-directed back to the login page.
-->
<?php
include ("../../Conn/dbaccess.php");
?>
<?php
# Check to see if the submit button was clicked and $_POST superglobals username and password are filled in.
# Then find the login record using the username and password.
# Username is intended to be an email address.
# To search a FileMaker record for an email adderss with an "@" character you have to use the search operator "==" for match entire field.
# Safari will url encode the @ symbol as %40. This means that you have to use the urldecode function to convert %40 back to @.
# Password can be anything. Notice the use of the MD5 hash to enrcypt the data as a 32-bit hexadecimal number. That would send '1234' as "81dc9bdb52d04dc20036dbd8313ed055'.
# For this to work, the password would also need to be stored in the database as a MD5 hash when the user creates their record.
if(isset($_POST['Login']) and (!empty($_POST['username']) and !empty($_POST['password'])) )
{
$username = '==' . urldecode($_POST['username']);
$password = md5($_POST['password']);
$request = $fm->newFindCommand('Demo php');
$request->addFindCriterion('UserName', $username);
$request->addFindCriterion('Password', $password);
$result = $request->execute();
# Check for errors if no records are found, find all all the records so FileMaker doesn't throw an error and crash the page.
if (FileMaker::isError($result))
{
$request = $fm->newFindAllCommand('Demo php');
$result = $request->execute();
}
# Set the $found variable with the number of records in the found set. There should only be 1 unique record.
$found = $result->getFoundSetCount();
if($found == 1)
{
# Set the $_SESSION superglobal 'login' value to 1 to indicate that the user is logged in.
# This value will be checked on all the protected pages before the user can access the page.
# Use the header() method to redirect the user to the LoginSuccess.php page.
$_SESSION['login']=1;
header("location:LoginSuccess.php");
exit;
}
else
# If there is more than one record in the found set set the $_SESSION 'login' value to 0.
# This will prevent users from accessing any of the protected pages.
# Set the $message variable to let the user know they tried an incorrect user name or password.
# Echo the $message in the html of the form.
{
$_SESSION['login']=0;
$message = 'Incorrect user name or password.';
}
}
else
# By default, the $message varible is set to ask the user to enter a user name and password.
# Echo the $message in the html of the form.
{
$message = 'Please enter a user name and password.';
}
?>
<form action="Login.php" method="post">
<table border="0" cellspacing="3" cellpadding="3">
<tr>
<td> </td>
<td><?php echo $message; ?></td>
</tr>
<tr>
<td>User Name</td>
<td><input name="username" type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<td> </td>
<td><input name="Login" type="submit" value="login" /></td>
</tr>
</table>
</form>
</body>
</html>
================
Строка 22: <?php
Строка 56: header("location:LoginSuccess.php");
Может кто-нибудь пролить свет на то, как исправить ошибку?
Заранее спасибо!
Пол