Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2006, 03:49 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in Chapter 12

Having a problem with the admin login in chapter 12. It doesn't redirect back to entry.php after putting in correct username and password. Instead I get an
"Internal Server Error:
The server encountered an internal error or misconfiguration and was unable to complete your request."

But when hitting the back button, I'll get to admin_area.php.

Why won't it redirect to entry.php?

Here's the code:
Code:
<?php
session_start();
include "conn.inc.php";

if (isset($_POST['submit'])) {
    $query = "SELECT 
            username, password
    FROM 
       admin
    WHERE
       username = '" . $_POST['username'] . "'
    AND 
       password = '" . $_POST['password'] . "' ";

//the = (password(... wouldn't work, removed it

    $result = mysql_query($query) or
            die(mysql_error());

    $row = mysql_fetch_array($result);

    if (mysql_num_rows($result) == 1) {
        $_SESSION['admin_logged'] = $_POST['username'];
        $_SESSION['admin_password'] = $_POST['password'];
        header("URL=" . $_POST['redirect'] . "");
    }
    else {
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<p>Invalid username, password, or both you schmuck!</p>
    <form action="admin_login.php" method="post">
        <input type="hidden" name="redirect" 
            value="<?php echo $_POST['redirect']; ?>" />
        <p>
        Username: <input type="text" name="username" />
        </p>
        <p>
        Password: <input type="password" name="password" />
        </p>
        <input type="submit" name="submit" value="Login" />
    </form>
</body>
</html>

<?php
  }
}
else {
    if(isset($_GET['redirect'])) {
        $redirect = $_GET['redirect'];
    }
    else {
        $redirect = "entry.php";
    }
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<p>log in</p>
    <form action="admin_login.php" method="post">
        <input type="hidden" name="redirect" 
            value="<?php echo $redirect; ?>" />
        <p>
        Username: <input type="text" name="username" />
        </p>
        <p>
        Password: <input type="password" name="password" />
        </p>
        <input type="submit" name="submit" value="Login" />
    </form>
</body>
</html>
<?php
}
?>
Thanks,
James




















Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 12 - $_POST['redirect'] problem cshu BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 July 25th, 2005 08:14 PM
Chapter 12 Code Behind Problem locknload7 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 March 30th, 2005 10:34 AM
Chapter 12 problem JB977 BOOK: Beginning ASP 3.0 11 March 9th, 2004 08:27 AM
Problem with Excel VBA Chapter 12 RogerWaters Excel VBA 0 September 22nd, 2003 10:13 AM
Chapter 12 problem Please help rsteph7 Beginning PHP 2 July 16th, 2003 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.