Jump to content


This topic is now archived and is closed to further replies.


1 Login Bug :S

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:


if ($_SESSION['login'] == 1){
echo "
:: Logged: <b>$naam</b>
:: <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>


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="">
<input name="username" type="text"  /><br>
<input name="password" type="password" /><br>
<input type="submit" name="submit" value="Login" />


Thanks in advance  ;D

Share this post

Link to post
Share on other sites


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.