Jump to content


Photo

1 Login Bug :S


  • Please log in to reply
No replies to this topic

#1 Nohtreya

Nohtreya
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 24 October 2006 - 04:08 AM

Hello 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:

<?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>

<?
}
}
?>

Thanks in advance  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users