PHP
database.php
<?php
class Database{
private $conn;
public function __construct($host,$user,$pass,$db){
$this->conn=mysqli_connect($host,$user,$pass,$db) or die("Connection Fail".mysqli_connect_error());
session_start();
}
/******************** for Login *************/
public function Login($table,$cols,$where){
$sql="SELECT $cols FROM $table WHERE $where";
$result=mysqli_query($this->conn,$sql);
if(mysqli_num_rows($result)>0){
$rows=mysqli_fetch_assoc($result);
$_SESSION['name']=$rows['name'];
return true;
}
else{
return false;
}
}
}
$obj=new Database("localhost","root","","loginlogout");
best
ReplyDelete