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

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.