<?php
try
{
$post=sanitize($_POST);
$staff_code=$post['code'];
$staff_pass=$post['pass'];
$staff_pass= md5($staff_pass);
$dsn = 'mysql:dbname=hoge;host=localhost;charset=utf8';
$user='root';
$password='';
$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sql = 'SELECT name FROM mst_staff WHERE code=? AND password=?';
$stmt = $dbh->prepare($sql);
$data[]=$staff_code;
$data[]=$staff_pass;
$stmt->execute($data);
$dbh =null;
$rec = $stmt->fetch(PDO::FETCH_ASSOC);
if($rec==false)
{
print 'スタッフコードかパスワードが間違っています。<br/>';
print '<a href="staff_login.html">戻る</a>';
}
else
{
// $recがtrueであればログイン成功です
session_start();
$_SESSION['login']=1;
$_SESSION['staff_code']=$staff_code;
$_SESSION['staff_name']=$rec['name'];
header('Location: staff_top.php');
exit();
}
}
catch(Exception $e)
{
print 'ただいま障害により大変ご迷惑をお掛けしております。';
exit();
}
?>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00