0

I was trying to create a simple login in html using phpmyadmin database and xampp server but then this error shows *Parse error: syntax error, unexpected '$password' (T_VARIABLE) *

Here's my code.

<?php

$username = $_POST['user']
//*here's the Erro// $password = $_POST['pass']

$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

mysql_connect("localhost", "root", "");
mysql_select_db("Login");

$result = mysql_query("select * from users where username = '$username' and password = '$password'") or die("Failed to query Database".mysql_error());

$row = mysql_fecth_array($result);

if ($row['username'] == $username && $row['password'] == $password ){
    echo "Login Succesful! Welcome" =.$row['username'];
}else {
    echo "Login Failed"
}

?>
Anthony Rutledge
  • 6,980
  • 2
  • 39
  • 44
NiewBiee2020
  • 29
  • 1
  • 10
  • 2
    missing `;` at end of `$username = $_POST['user']` – Sean Feb 26 '17 at 06:14
  • i put `;` at the end of both `$username = $_POST['user']` and `$password = $_POST['pass']` and there's another error, says "Parse error: syntax error, unexpected '=', expecting ',' or ';' in C:\xampp\htdocs\Logintry1\bs-advance-admin\advance-admin\loginpro.php on line 23" – NiewBiee2020 Feb 26 '17 at 06:19
  • 4
    Pease don't use `mysql` functions. they have deprecated. use [mysqli](http://php.net/manual/en/book.mysqli.php) or [PDO](http://php.net/manual/en/book.pdo.php) – gaurav Feb 26 '17 at 06:19
  • thank you for the ref's :) sorry i'm newbie in html and mysql – NiewBiee2020 Feb 26 '17 at 06:33

2 Answers2

2

You forgot the semi-colon.

$username = $_POST['user'];

You also forgot it here.

echo "Login Failed";
Anthony Rutledge
  • 6,980
  • 2
  • 39
  • 44
0

You have multiple errors:

<?php

$username = $_POST['user']; //<-------put ';'
//*here's the Erro// $password = $_POST['pass']


$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);



mysql_connect("localhost", "root", "");
mysql_select_db("Login");


$result = mysql_query("select * from users where username = '$username' and password = '$password'") or die("Failed to query Database".mysql_error());

$row = mysql_fecth_array($result);

if ($row['username'] == $username && $row['password'] == $password ){
echo "Login Succesful! Welcome =".$row['username']; //<-------change this line
}else {
echo "Login Failed";//<-------put ';'

}

?>
B. Desai
  • 16,414
  • 5
  • 26
  • 47