Jump to content

some simple mistake with empty


arbitter

Recommended Posts

if(($_GET['fx'] == 'account') && isset($_POST['changepas']))
	{
		$old_pas = $_POST['old_pas'];
		$new_pas = $_POST['new_pas'];
		$new_pas2 = $_POST['new_pas2'];
		if(empty($old_pas) || empty($new_pas) || empty($new_pas2))
		{
			$_SESSION['message'] = 'You must fill in all the fields.';
			header("Location: index.php?fx=account");
		}
		$verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Connection failed: " . mysql_error());
		mysql_select_db('users');
		$result = mysql_query("SELECT * FROM users WHERE email='" . $_SESSION['email'] . "' AND nick='" . $_SESSION['nick'] . "'");
		$row = mysql_fetch_array($result);

		if(empty($row))
		{
			$_SESSION['message'] = 'There is a problem with the server';
			header("Location: index.php?fx=account");
		}
		if($old_pas != $row['password'])
		{
			$_SESSION['message'] = 'your password does not match.';
			header('Location: index.php?fx=account');
		}
		if($new_pas != $new_pas2)
		{
			$_SESSION['message'] = 'The new passwords dont match.';
			header("Location: index.php?fx=account");
		}


	}

 

So when I don't fill in my form (leave every field empty); I get the message 'your password does not match.', but it should give that not all fields are filled in.

 

I really do not see my mistake..

Link to comment
https://forums.phpfreaks.com/topic/201182-some-simple-mistake-with-empty/
Share on other sites

A header() statement JUST sends a header to the browser. It has no affect on the php script, which continues execution after the header() statement until it gets to the end of the file or an exit/die statement.

aaaah I see!

I didn't know that, but I guess you already knew I didn't know that.

Thanks for the further explanation!

Archived

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

×
×
  • 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.