Я слежу за видеоуроком по php (он не онлайн, извините) от Lynda.com и использовал следующий код, но я получил следующую ошибку
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
это может быть проблема с моим кодом,то есть тот факт, что код имеет две redirect_to
в первых 10 или 15 строках, или речь идет о чем-то еще?
<?php require_once("../../includes/initialize.php"); ?>
<? if(!$session->is_logged_in()){
redirect_to("login.php"); } ?>
<?php
$logfile = SITE_ROOT.DS.'logs'.DS.'log.txt';
if($_GET['clear'] == 'true') {
file_put_contents($logfile, '');
//add the first log entry
log_action('Logs Cleared', "by User ID {$session->user_id}");
//redirect to this same page so that the URL won't
//have "clear=true" anymore
redirect_to('logfile.php');
}
?>
<?php include_layout_templates('admin_header.php');?>
<a href="index.php">« Back</a><br/>
<br/>
<h2>Log File</h2>
<p><a href="logfile.php?clear=true">Clear log file</a></p>
<?php
if (file_exists($logfile) && is_readable($logfile) &&
$handle = fopen($logfile, 'r')) {//read
echo "<ul class=\"logentries\">";
while(!feof($handle)) {
$entry = fgets($handle);
if(trim($entry) != "") {
echo "<li>{$entry}</li>";
}
}
echo "</ul>";
fclose($handle);
} else {
echo "Could not read from {$logfile}.";
}
?>
//Remember to give your form's submit tag a name="submit" attribute
if (isset($_POST['submit'])) {//Form has been submitted.
$username = trim($_POST['username']);
$password = trim($_POST['password']);
//Check database to see if username/password exist
$found_user = User::authenticate($username, $password);
if ($found_user) {
$session->login($found_user);
log_action('Login', "{$found_user->username} loggined in.");
redirect_to("index.php");
} else {
//username/password combo was not found in the database
$message = "Username/password combination incorrect.";
}
} else {//Form has not been submitted.
$username = "";
$password = "";
}
?>
<?php include_layout_template('admin_header.php'); ?>
<h2>Staff Login</h2>
<?php echo output_message($message); ?>
<form action="login.php" method="post">
<table>
<tr>
<td>Username:</td>
<td>
<input type="text" name="username" maxlength="30" value="<?php
echo htmlentities($username); ?>" />
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="password" maxlength="30" value="<?php
echo htmlentities($password); ?>" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value="login" />
</td>
</tr>
</table>
</form>
<?php include_layout_template('admin_footer.php'); ?>