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

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

Needing Youtube thumb nail fix.
I have a script on a site that pulls in you-tube videos,
The problem is, that the thumb nails for

Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doi

array_map() probably obvious mistake
The code below is part of a class to escape strings, but should also accept an array, using array_ma

A Few Questions
Hi, I want to ask a few questions that I can't seem to find..

1) I'm creating a "shortcu

cURL and Sessions
Ohai.

So, I'm trying to cURL a bunch of things off of a page, and put them into a session. I'

Parse Error Help
Hello, I got the parse error "Parse error: syntax error, unexpected ',' in register.php on line

Form errors in an array
I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the tric

Update Database
Hi All,


I have a problem with this:

Code: [Select]<?php
session_start();

firefox wouldnt stream mp3 files completely from my php page
hi everyone,
I have a php file trying to read and stream mp3 files. It works fine in IE but my pr

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