Need help with a login form.
Login.php
<html> <head> <title>Basic CMS - Admin Area Login</title> </head> <body> <?php session_start(); if(isset($_SESSION['user'])) { header('Location: index.php'); } else { ?> <form action="dologin.php" method="POST" > <input type="text" name="username" > <input type="password" name="password"> <input type="submit" value="Login"> <?php } ?> </body> </html>
<?php
include ('../includes/functions.php');
if(isset($_POST['login'])) {
if(isset($_POST['username'])) {
if(isset($_POST['password'])) {
$username = $_POST['username'];
$query = mysql_query("SELECT * FROM users WHERE Username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
if ($_POST['password'] == $user['Password']) {
echo "Login successful";
$_SESSION['user'] = $user['Username'];
header("Location: index.php");
} else {
echo "Please check your login details";
include('login.php');
}
} else {
echo "Please check your password";
include('login.php');
}
} else {
echo "Please check your username";
include('login.php');
}
} else {
echo "Please check that you have filled out the login form";
include('login.php');
}
?>
-
Andrew H -
Thanks
Signature"You shouldn't come here and set yourself up as the resident wizard of oz." {{ DiscussionBoard.errors[8585198].message }} -
-
man5 -
Thanks
Signaturewww.imdabest.ca{{ DiscussionBoard.errors[8585251].message }} -
-
Andrew H -
Thanks
Signature"You shouldn't come here and set yourself up as the resident wizard of oz." {{ DiscussionBoard.errors[8585429].message }} -
-
Andrew H -
Thanks
Signature"You shouldn't come here and set yourself up as the resident wizard of oz." {{ DiscussionBoard.errors[8585439].message }} -
-
man5 -
Thanks
Signaturewww.imdabest.ca{{ DiscussionBoard.errors[8585465].message }} -
-
Andrew H -
Thanks - 1 reply
Signature"You shouldn't come here and set yourself up as the resident wizard of oz." {{ DiscussionBoard.errors[8585521].message }}-
man5 -
Thanks
Signaturewww.imdabest.ca{{ DiscussionBoard.errors[8585563].message }} -
-