Jump to content

1 Login Bug :S


Nohtreya

Recommended Posts

[b]H[/b]ello all php´ers!

I have an Login script dat works with Sessions and Mysql!

But I have one problem:
If you enter the username RIGHT but the password WRONG it shows a blank page :S

But if I enter another input it shows the right Error text :S

Here is my script:

[code]
<?php
session_start();

if ($_SESSION['login'] == 1){
echo "
:: Logged: <b>$naam</b>
<hr>
:: <a href='index.php?page=regist'>Register a customer</a><br>
:: <a href='index.php?page=list_klachten'>View list</a><br>
:: <a href='index.php?page=logout'>Logout</a><br>
";

}else{

if($_POST['submit']) {

$query = mysql_query("SELECT * FROM helpdesk_login WHERE gebruikersnaam = '".$_POST['username']."'") or die (mysql_error());
  $result = mysql_fetch_object($query);
  $naam = $result->gebruikersnaam;
  $wachtwoord = $result->wachtwoord;
  $session_id = $result->type;

if(!$_POST['username'] == "$naam" || !$_POST['password'] == "$wachtwoord") {
  echo "The data are not correctly!<br><br><a href='javascript:history.back(1)'><u>Return</u></a><br><br>";
  echo "<br />";
} elseif($session_id == 0) {
print "You're account isn't activated yet.<br><br><a href='javascript:history.back(1)'><u>Return</u></a><br><br>";
} else {

if($_POST['username'] == "$naam"  && $_POST['password'] == "$wachtwoord") {
  $_SESSION['username'] = $naam;

if ($session_id == '1'){
  $_SESSION['login'] = "1";
}

$_SESSION['naam'] = $naam;

  echo "Now logged in as: <b>$naam</b><br><br>Click <a href='index.php'>here</a> to continue.";
}
}

} else {

?>
<form name="form1" method="post" action="">
Username:<br>
<input name="username" type="text"  /><br>
<br>
Password:<br>
<input name="password" type="password" /><br>
<br>
<input type="submit" name="submit" value="Login" />
</form>

<?
}
}
?>
[/code]

Thanks in advance  ;D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.