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

why this query can delete duplicates ?
why this query can delete duplicates ? Anybody can give me the detailed explanation ?

Tha

php and downloading
I want to use a php script to create two files. Then I want it to redirect (or whatever) to have tho

phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";

JSON SORT WITH PHP
I have two products that I want to sort by say "Id:17, value: xxx" using php
The page w

Multipe Dynamic Controls & AutoPostback Issue
I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBa

need to add "sizes" to shopping cart
Hey guys, I am trying to figure out a way to add a "size" selector on to this bit of code.

Creating a unique 'control panel' for each user
Hi there,

I'm thinking of designing a site that will allow users to sign up and have their ow

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

Using Microsoft Exchange Server with PHP
Hi,

I wanted to know if its possible to fetch email attachments from the exchange server usin

Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of

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