Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2006, 03:49 PM
Registered User
 
Join Date: Jul 2006
Location: , , .
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















Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.