I created a registration form that works fine in php for a project I am undertaking. I attempt to use another form, a login form in which to pull the username and password data from the user to verify it against the database. However I am getting parsing errors and other errors. I haven't started validation yet as I haven't got the basics in this ready.
I don't think I'm going about this the right way or if it's just a silly mistake.
<EDIT Remove Important Info>
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
if (isset($_SESSION['logged'])){ //already logged in
//$url= 'X'; // any page
exit(); //ends script if user already logged in
} else { //not logged in or submitted
}
$user_name = mysqli_real_escape_string($con,$_POST['username']);
$pass = mysqli_real_escape_string($con,$_POST['password']);
$notify="";
if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box'];
$query=mysqli_query($con,"SELECT * FROM `websiteusers` WHERE username ='$user_name' AND password ='$pass'");
$count = $mysqli_num_rows($query); //checks db
$row = mysqli_fetch_array($query);
if($count==0){ //db empty
echo "Sorry, password and username not in db. Click here to try again.";
}
else{ // pw and un match, user login success
$_SESSION['logged']=1; //start session
$_Session['username']=$user_name; //session data
}
// } // opening brace for this was not found
mysqli_close($con);
exit();
} // opening brace for this was not found
?>