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.

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

gettext translates ALWAYS?
I'm using gettext with the new version of XAMPP (5.3.0) on Windows Seven RTM (build 7600)
gettext

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

A little help needed passing hidden values to next page
I have a page that has hidden values in a form.

example
Code: <input name='signupID

Staff Induction System - No idea where to go from here!!!
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables an

COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i

CRM?
I think that's what they're called. Customer Management System? Anyway. Is there any good free ones

Preg_match with an array
is there an away to use preg_match with an array?

i want to check a string with an array to s

Displaying values from a SQL count...
Hi,
Easy enough question i just forget the exact method ..
I have ...

Code: //count win

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

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