Jump to content

php login


lukerodham

Recommended Posts

hi guys me again. kinda stuck, im trying to turn my admin login script in to a user login with the admin side of things, so to keep things separate. for some reason the include function is not working after its checked, if the user is a admin or not. any ideas on why this would not work? have i done something completely wrong or just missing something.

 

ive left the code below, if it helps aswell the login.php is a included file aswell to index.php.

 

thanks in advance.

 

login.php


<?php

$userback = $_SESSION['user'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$login = $_post['submit'];

mysql_connect("db2700.oneandone.co.uk","dbo363845380","notgonnalie12");
mysql_select_db("db363845380") or die(mysql_error());

session_start(); 
if($_SERVER['QUERY_STRING'] == "logout") {
unset($_SESSION['user']);
header("Location: " . $_SERVER['PHP_SELF']);
exit;
}
if(!isset($_SESSION['user'])){
    if(!$submit){
   echo"<div align='center'><b>Please login</b></div><br>";
   echo "
        <html>
        <body>
        <div align='center'>
        <form method='post' action='".$_SERVER['REQUEST_URI']."'>
        <label>username: 
        <input type='text' name='username' id='username'>
        <label>password: 
        <input type='password' name='password' id='password'>
        </label>
        <label>
        <input type='submit' name='submit' id='submit' value='submit'>
        </label>
        </form>
        </div>
        </body>
        </html>
        ";	
}
    else {
        $rows = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($username)."' AND password='".mysql_real_escape_string($password)."'"));
        if($rows>0){
            while ($row = mysql_fetch_assoc($rows)){
                $_SESSION['user']="$username";
            
                $adminpass = $row['admin'];
            
                if($adminpass>=1){
                    include ("admin/index.php");
                }
                else {
                    echo "welcome $user1 you'll be directed in a few seconds.<br> if this doesn't happen please click here.";
                }
            }
        }
        else {
            if($rows<1){
                echo "Sorry no user information found. Please make sure details are correct.";
            }
        }
    }
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.