[Forum] Syntax error database
Bonsoir, j'ai commencé le PHP aujourd'hui j'ai suivis un tutoriel à la lettre à la fin de celui-ci une erreur s'affiche..
Citation:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\Login.php on line 59
Je suppose donc que l'erreur vient d'un problème de connexion avec MySQL ? J'ai cherché pendant 2h mais rien n'y fait, j'ai même recommencé le tutoriel.. je vois pas l'erreur à la ligne 59..
Je viens donc aujourd'hui chercher de l'aide sur ce forum si ça ne dérange pas bien sur ! :oops:
Voici les codes:
index.php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content=="text/html; charset=utf-8">
<title>Connexion</title>
</head>
<body>
<form name="loginform" action="Login.php" method="POST">
<table>
<tr>
<tr><td>E-mail</td><td><input type ="email" name="Email" placeholder="E-mail..." /></td>
<tr><td>Password</td><td><input type ="password" name="Password" placeholder="Password..." /></td>
<td><input type="submit" name="submit" value="Sign In" ></td>
</tr>
</table>
</form>
</body>
</html> |
Login.php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <?php
session_start();
require_once('connect.php');
if (!isset($_SESSION['Email']) && isset($_POST['Email'])) {
# code...
if (!empty($_POST['Email']) && !empty($_POST['Password'])) {
# code... FILTER_SANITIZE_STRING
$email = filter_var($_POST['Email'], FILTER_SANITIZE_STRING);
$password = filter_var($_POST['Password'], FILTER_SANITIZE_STRING);
$password=shal($password);
try {
$cnx = new PDO("mysql:host=$Host; dbname=$Database", $User, $Password);
$cnx -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$email = $_POST['Email'];
$password = $_POST['Password'];
$stat = $cnx -> prepare("SELECT Email, Password FROM User WHERE Email = '".$email."' and Password = '".$password."'");
$stmt -> bindParam('".$email."', $email, PDO::PARAM_STR);
$stmt -> bindParam('".$password."', $password, PDO::PARAM_STR);
$stmt -> EXECUTE();
$em = $stmt -> fetchColumn();
if ($em == true) {
# code...
session_register("Email");
session_register("Password");
$_SESSION['Email'] = $_POST['Email'];
$_SESSION['START'] = time();
setcookie("User", $_POST['Email'], mktime()+(60*3), "/");
setcookie("LUS", time(), mktime()+(60*3), "/");
$stmt -> $cnx -> prepare("SELECT Name FROM User WHERE Email = '".$email."'");
$stmt -> EXECUTE();
$em2 = $stmt -> fetchColumn();
echo "Logged in.";
} else {
echo "E-mail or Password Incorrect.";
}
} catch (Exception $e) {
echo "".$e->getMessage();
}
} elseif (empty($_POST['Email']) && !empty($_POST['Password'])) {
# code...
echo "<font color='red'> Error : Enter your E-mail.</fond>";
} elseif (!empty($_POST['Email']) && empty($_POST['Password'])) {
# code...
echo "<font color='red'> Error : Enter your Password.</font>";
} else {
echo "<font color='red'> Error : Enter your E-mail & Password.</font>.
}
}
elseif(isset($_SESSION['Email'])) {
# code...
echo "Welcome again you still logged in <strong>".round((time() - $_SESSION['START'])/60)."</strong> minute(s) ago <a href='Logout.php'>LogOut</a>";
}
elseif(!isset($_SESSION['Email'])) {
# code...
echo "You must loggin first.";
include('index.php');
}
?> |
Connect.php:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <?php
include('Security');
$Host= 'localhost';
$User = 'root';
$Password = '';
$Database = 'dvrdatabase';
ORM::configure("mysql:host=$Host; dbname=$Database");
ORM::configure('username' , $User);
ORM::configure('password' , $Password);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
?> |
Merci d'avoir pris le temps de me lire bye bye ! :)