So, I was trying to write a PHP authentication system, but I cannot run it without getting an error. Specifically, it says the following:
Parse error: syntax error, unexpected '$name' (T_VARIABLE) in C:\Apache24\htdocs\struct\generalesourcesoot~index\User.php on line 6
I then looked it up, and found out that the error was a common one. However, what was different about mine was that the '$name' variable didn't actually exist. In fact, line 6 is the closing bracket of a function. Here is the full code:
<?php
include 'User.php';
function sha512($data){
return hash('sha512', $data);
}//This is line 6
?>
<html><head><title>Login</title></head><body background="/struct/general/resources/root~index/images/Pig.jpg"<p>Your request is being processed. Please Wait...</p><br />
<?php
$username = htmlspecialchars($_POST['__INPUT_2']);
$passwordhash = sha512(htmlspecialchars($_POST['__INPUT_1']));
$user_file_path = $_SERVER['DOCUMENT_ROOT'] . '/struct/data/user/data';
$isUser = file_exists($user_file_path . $username . '$' . $passwordhash);
$user = new User($username, $passwordhash);
?>
By the way, I am somewhat of a beginner to PHP, so I'm not sure if I matched all the conventions correctly. Anyways, my question is this: Why am I getting an error about a mysterious variable called '$name' when that variable does not exist within the scope of my code, and how should I fix this?