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

GET vs SUBMIT Button to show sections on one index.php page?
Just curious if one of these ways is better (i.e. more efficient) than the other.

I have a

Display the user's weight lost in the past week
Hello everyone,

I am working on a weight loss app for my site, and I want to display the user

PHP Game
hy i was wondering what's the best method in order to make some automatic updates in a php game
<

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

remove trailing slash from array
I have the following array which contains trailing slashes I need to remove. What is the best way to

What are the two different files you download to update kernel?
What are the two different files you download to update kernel?

Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..

Last Weeks sDate and eDate.
sDate - Start Date
eDate - End Date

I need to pull two dates for "Last Week" whi

session_destroy();
new to php
I have a simple login and am trying to write a logout.
I set a $_SESSION var to 1 i

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

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