I am new in this forum. I am a php mysql starter.
please help me see what is wrong with this code:
It is giving me parse error

<?php
$dbhost='localhost';
$dbusername='root';
$dbuserpass='';
$dbname='users';

if (isset($_COOKIE['user'])) {
echo "Welcome $_COOKIE[user]";
}else{
//connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');

if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "A password was not supplied";
}else{
$query = mysql_query("SELECT username,password FROM userstable WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "The supplied login is incorrect";
}else{
$query = mysql_query("SELECT username,password FROM userstable WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
setcookie("user", "$username", time()+3600);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=membersarea.php\">";

?>

A) we can tell you're new, you didn't read that you should use code tags.
B) You're missing all of your closing tags.

}
    }
  }
}

should go right before the end tag

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.