login page does not execute a else statement


Posted on 16th Feb 2014 07:03 pm by admin

I've created a login page using sessions.
When an incorrect user name or password is entered then a custom messege error message apears.

But if a correct user name and password is used then notthing happens, no error message and I'm still on the login form.
Did you know?Explore Trending and Topic pages for more stories like this.

This is the code below.
What am I'm doing wrong?

Code:
<?php
include("config.php");

$id = strip_tags($_GET['id']);

if ($id == "do") {
$user = strip_tags($_POST['username']);
$pass = strip_tags($_POST['password']);

if ($user == $username and $pass == $password) {

session_start();
session_register('authorized');
$_SESSION['authorized'] = true;

header("Location: admin.php");
exit;

} else {
echo "<p>Incorect Username or/and Password, Please Go back and try again.</p>";
}
} else {

?>
<form method="POST" action="login.php?id=do">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Login">
</form>
<?php
}
?>
No comments posted yet

Your Answer:

Login to answer
108 Like 21 Dislike
Previous forums Next forums
Other forums

a very simple php header question (sorry!)
Firstly...I do apologise if this annoys anyone....a header error

I'm do not know php &

php redirecting
i wont open a new thread but i have a question about redirecting....
i wonder why my code doesnt

foreach iterator
Hi Guys
Does the foreach loop have an inbuilt iterator ?

Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not reall

Windows 7
Windows 7 default user account control worries experts. Corporate IT departments should be pleased w

Problem Dereferencing
With these types and tables:

CREATE TYPE MANAGER AS OBJECT (
MGR_ID INTEGER,

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an

Creating Images from images in PHP
Okay well I am trying to make a 'dynamic' calender image with PHP.

I have images like this:

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash