0

I have a problem with an error when using php:

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\login.php on line 18

And this is my login.php:

if (isset ($_GET ['submit'])) {
    $username = $_POST['username'];
  $check_username = mysql_query ("SELECT * FROM users WHERE username='$username'");
  $numrows = mysql_num_rows ($username);
  if ($numrows != 1) {
    echo 'that User doesn\'t exist.';
}

?>
<h2>Login to your Account</h2>
<form action='login.php' method='POST'>
<input type='text' name='username' value='Username ...' onclick='value=""' /><p />
<input type='password' name='password' value='Password ...' onclick='value=""' /><p />
<input type='submit' name='submit' value='Login to my Accou`nt' />
</form>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Teminite
  • 1
  • 1
  • 1
    You've a missing brace for `if (isset ($_GET ['submit'])) {` once you fix that, your next error will be undefined index submit and chose that one to close your question with. – Funk Forty Niner Jan 27 '16 at 19:17
  • [Your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Jay Blanchard Jan 27 '16 at 19:30
  • Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jan 27 '16 at 19:30
  • Please use PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html) to handle password security. If you're using a PHP version less than 5.5 you can use the `password_hash()` [compatibility pack](https://github.com/ircmaxell/password_compat). – Jay Blanchard Jan 27 '16 at 19:31

0 Answers0