只是从 mysql_ 转换为 PDO。当然会出现一些错误。
<?php
ob_start();
session_start();
include("php/connect.php");
if ($_POST['submit']){
$username = $db -> prepare($_POST['username']);
$password = $db -> prepare($_POST['password']);
if($username){
if($password){
$password = md5(md5("KmsdufIFNKSnefndbdo19228330293".$password."JSDSHBFJS8S8ds8sd8s8d"));
$query = $db -> query("SELECT * FROM user WHERE username='$username'");
$num_rows = $db -> rowCount($query);
if ($num_rows == 1){
$row = $query -> fetch(PDO::FETCH_ASSOC);
$db_username = $row['username'];
$db_password = $row['password'];
if ($password == $db_password){
$_SESSION['username'] = $username;
}else
$div = "<div id='error'>Passwordi eshte gabim</div>";
}else
$div = "<div id='error'>Emri nuk u gjend</div>";
}else
$div = "<div id='error'>Futeni Passwordin</div>";
}else
$div= "<div id='error'>Futeni emrin e llogarise</div>";
}
?>