0

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\">";

?>
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by ShawnCplus
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.