Subject: Chapter 12 - Not redirect or connect with user
Posted By: Alejor Post Date: 1/5/2006 5:25:31 PM
Hello,

I write all codes of the book but when I try access with admin.login.php with my login and password send me a this URL :
http://www.xxxx/admin_login.php?redirect=index.php&username=aaa&password=aaa&submit=login

and not the admin_area.php

I change in db admin the field admin_level 0,1,2 but I not solve the problem.

This is  admin.login.php
---------------------------------
<?php
session_start();
include "conn.inc.php";

if (isset($_POST['submit'])) {
    $query ="SELECT username, password, admin_level FROM admin WHERE username ='".$_POST['username']."' AND password=(password('".$_POST['password']."'))";
    $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'];
        $_SESSION['admin_level'] = $row['admin_level'];
        header("Refresh:5; URL=".$_POST['redirect']."");
        echo "You are being redirected to our original page request!<br>";
        echo "(If our browser doesn't support this, ".
        "<a href=\"".$_POST['redirect']."\">Click here</a>)";
    } else {
?>
        
<html>
<head>
<title> ERROR IN ADMIN ZONE </title>
</head>
<body>
<p>
Invalid Username or Password!<br>
<form action="admin_login.php" method="post">
<input type="hidden" name="redirect"
    value="<?php echo $_POST['redirect']; ?>">
    Username: <input type="text" name="username"><br>
    Password" <input type="password" name="password"><br><br>
    <input type="submit" name="submit" value="login">
    </form>
    </p>
    </body>
    </html>
    <?php
    }
}else{
    if (isset($_GET['redirect'])) {
        $redirect = $_GET['redirect'];
    } else {
        $redirect = "index.php";
    }
?>
<html>
<head>
<title> Admin Zone </title>
</head>
<body>
<p>
Login below by supplying your username/password...<br>
<form action="admin_login.php" action="post">
<input type="hidden" name="redirect"
    value="<?php echo $redirect; ?>">
    Username: <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br><br>
    <input type="submit" name="submit" value="login">
</form>
</p>
</body>
</html>
<?php
}
?>
----------------------------------------

Could your help me with this file.



Alerian.net
WebDesign in Spanish

Go to topic 38113

Return to index page 402
Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394
Return to index page 393