It's going to drive me crazy ... So, What am i doing wrong ? Where is my error ?
When i try to connect, it always show me the result where user and password are wrong even they're right ...
If someone has an idea to implement session also ?
Thanks in advance for your help
Peace & Unity !
Here's the beast !
INDEX.PHP
<?php
include_once('user.php');
if(isset($_POST[submit])){
$name = $_POST['login'];
$pass = $_POST['password'];
$object = new User() ;
$object->Login($name, $pass);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form method="post" action="index.php">
login : <input type="text" name="login" /><br>
password : <input type="text" name="password" />
<input type="submit" name="submit" value="login" />
</form>
</body>
</html>
dbConnect.php
<?php
class Connection {
public function dbConnect(){
return new PDO("mysql:host=localhost; dbname:test","root","");
}
}
?>
USER.PHP
<?php
include_once('dbConnect.php');
Class User {
//Start Construct
Private $db;
public function __construct () {
$this->db = new Connection();
$this->db = $this->db->dbConnect();
}
// End Construct
public function Login($name, $pass) {
if(!empty($name) && !empty($pass)){
$st = $this->db->prepare("SELECT * FROM user Where user_login=? AND user_pass=?");
$st->bindParam(1, $name);
$st->bindParam(2, $pass);
$st->execute();
if($st->rowCount() == 1){
echo "User Connected";
}else{
echo "Vachez ta mère";
}
}else{
echo "Enter a valid Login and Password";
}
}
}
?>