-1
좋아요. pdo를 처음 사용하고 간단한 로그인 시스템을 만들었지 만 사용자 이름이나 암호를 공백으로 남겨 두었을 때 팝업 메시지가 뜨지는 않지만 운이 없다면 연구와 다른 사람들의 도움을 통해이 코드를 작성하십시오. 그러나 나는 지금 당황 스럽습니다. 어떤 도움이라도 나는 이것에 대해 새롭다는 것을 명심해야한다. 내가 이것을 알고pdo 오류 메시지 팝업 오류
P.S 여기
<?php
session_start();
//connection String
$connection = new PDO("sqlsrv:server=server;Database=database", "username", "password");
//Seelcting function
$smt = $connection->prepare("select user_id, username from account where username = :username and password =:password");
//setting values to textboxes
$username = $_POST["txt_username"];
$password = $_POST["txt_password"];
//binding values
$smt->bindParam(':username', $username);
$smt->bindParam(':password', $password);
//execution
$smt->execute();
//fetching data
$row = $smt->fetch(PDO::FETCH_ASSOC) ;
echo "$row[user_id]\n\n";
echo "$row[username]\n\n";
$_SESSION{"user_id"} = $row["user_id"];
if ($smt->recordCount() == 0){
$_SESSION['errormsg'] = "login failed";
header("location: login.php");
} else{
header("location: homepage.php");
}
if(isset($_SESSION['errormsg'])) {
// do the output
echo $_SESSION['errormsg'];
// delete the message from the session, so that we show it only once
unset($_SESSION['errormsg']);
}
?>
및 http://stackoverflow.com/questions/16834106/php-pdo-echo-alert-error –
두 번 이상 같은 질문을하지 마십시오. –
다른 계정을 사용 중입니다. – andrewsi