登録順に積み上げたコードとmd5方式で暗号化したパスワードでSELECT文を使ってログインシステムを作っていて構文エラーの質問をさせていただきました。
ご指導通りWEHREの入力ミスを直し構文エラーは解消したのですが今度は、
else
{
header('Location:staff_top.php');
}
の場所に
errorInfo=Array ( [0] => 00000 [1] => [2] => )
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\floris_slider\staff_l0gin\staff_login_check.php:31) in C:\xampp\htdocs\floris_slider\staff_l0gin\staff_login_check.php on line 41という警告が出てしまいましたので、どう対処すればよいかを教えていただけませんでしょうかお願いいたします。
再度、データーを表示いたします。
DB構造
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| performance_schema |
| phpmyadmin |
| shopdb |
| test |
| webauth |
+--------------------+
8 rows in set (0.00 sec)
mysql> show tables;
+------------------+
| Tables_in_shopdb |
+------------------+
| mst_product |
| mst_staff |
+------------------+
2 rows in set (0.00 sec)
mysql> show fields from mst_staff;
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| code | int(11) | NO | PRI | NULL | auto_increment |
| staff_namae | varchar(20) | NO | | NULL | |
| staff_pass | varchar(32) | NO | | NULL | |
+-------------+-------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)
ログイン入力
try
{
if (isset($_POST["staff_code"])) {
$staff_code = $_POST['staff_code'];
}
if (isset($_POST["staff_pass"])) {
$staff_pass = $_POST['staff_pass'];
}
$staff_code = htmlspecialchars($staff_code);
$staff_pass = htmlspecialchars($staff_pass);
$staff_pass=md5($staff_pass);
$dsn='mysql:dbname=shopdb;host=localhost';
$user='root';
$password='';
$dbh=new PDO($dsn,$user,$password);
$dbh->query('SETNAMES utf8');
$sql = 'SELECT staff_namae FROM mst_staff WHERE code=? AND staff_pass=?';
$stmt = $dbh->prepare($sql);
$data[0]=$staff_code;
$data[1]=$staff_pass;
$stmt->execute($data);
$dbh = null;
print '<p>errorInfo='.print_r($stmt->errorInfo(), true)."</p>\n";
$rec = $stmt->fetch(PDO::FETCH_ASSOC);
if($rec==false)
{
print 'スタッフコードか名前が間違っています。<br />';
print '<h3><a href="staff_login.html">戻る</a></h3>';
}
else
{
header('Location:staff_top.php');
}
}
catch (Exception $e)
{
print 'ただいま障害により大変ご迷惑をおかけしております。';
exit();
}
?>
エラーインフォ
errorInfo=Array ( [0] => 00000 [1] => [2] => )
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\floris_slider\staff_l0gin\staff_login_check.php:31) in C:\xampp\htdocs\floris_slider\staff_l0gin\staff_login_check.php on line 41
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/01/15 05:04