Sebelumnya salam kenal utk mba
@awaliah . biasanya ( kalau saya ya ) bisanya pada form action. Coba pastekan code popup-index.php dan class.usernya
mungkin saya bisa bantu
code class.user
<?php
ob_start();
class Database
{
private $host ="localhost";
private $db_name ="id2812472_dbbutawarna";
private $username ="id2812472_dbwarna";
private $password ="warna123";
public $conn;
public function dbConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $exception)
{
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
class USER
{
private $conn;
public function dbConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $exception)
{
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function register($uname,$umail,$upass,$nmpasien,$tmplahir,$tgllahir,$jk,$kerja,$hp,$alamat)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO users(user_name,user_email,user_pass,nmpasien,tmplahir,tgllahir,jk,kerja,hp,alamat)
VALUES ( :uname, :umail, :upass, :nm, :tmp, :tgl, :jk, :kerja, :hp, :alamat)");
$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->bindparam(":nm", $nmpasien);
$stmt->bindparam(":tmp", $tmplahir);
$stmt->bindparam(":tgl", $tgllahir);
$stmt->bindparam(":jk", $jk);
$stmt->bindparam(":kerja", $kerja);
$stmt->bindparam(":hp", $hp);
$stmt->bindparam(":alamat", $alamat);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function doLogin($uname,$umail,$upass)
{
try
{
$stmt = $this->conn->prepare("SELECT user_id, user_name, user_email, user_pass FROM users WHERE user_name=:uname OR user_email=:umail ");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(password_verify($upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
public function is_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}
public function redirect($url)
{
header("location: $url");
}
public function doLogout()
{
session_destroy();
unset($_SESSION['user_session']);
return true;
}
public function feedback($uid,$feedback)
{
try
{
$stmt = $this->conn->prepare("UPDATE users SET feedback=:fb WHERE user_id=:uid");
$stmt->bindparam(":uid", $uid);
$stmt->bindparam(":fb", $feedback);
$stmt->execute();
return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
ob_end_flush();
?>