Jump to content

Mysql dies with invalid user name or pass


jack7076
Go to solution Solved by Jacques1,

Recommended Posts

Hello I've written some code that dies when the msql lookup occurs and crashes when an invalid username or password is entered I want the code to continue and go to my invalid page. anyway here is the code:

echo "Before Query <br>";
	$query = mysql_query("SELECT *  FROM user where userName = '$_POST[user]' AND pass = '$pass'") or die(mysql_error());
	echo "row";
	$row = mysql_fetch_array($query) or die(mysql_error());
	echo "Before Login. <br>";
	if(!empty($row['userName']) AND !empty($row['pass']))
	{
		if($_POST['user'] = $row['userName'] AND $pass = $row['pass']){
		$_SESSION['ID'] = $row['ID'];
		$_SESSION['user'] = $row['userName'];
		$_SESSION['rank'] = $row['rank'];
		header("Location: Index.php");

	}
	else{
		header("Location: INVALID.php?ref=login");
	}
}
else
	{
		header("Location: INVALID.php?ref=login");
	}
Link to comment
Share on other sites

  • Solution

Erase the code from your disk, forget what you think you know about PHP, start from scratch

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.