 |
|
ช่วยดูโค็ดหน่อยครับ เหมือนจะติดต่อดาต้าเบสไม่ได้
selec_staff.php ไฟล์ที่ใช้แสดง
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #66F;
}
</style>
</head>
<body>
<table width="926" height="418" border="1">
<tr>
<td colspan="2" align="center">กรุณาเลือกการทำงานของคุณ</td>
</tr>
<tr>
<td width="456" align="center"><form id="form1" name="form1" method="post" action="../jp/repair.php">
<a href="repair.php">แจ้งซ้อมอุปกรณ์</a><a href="../jp/repair.php">์ </a>
</form></td>
<td width="454" align="center"><form id="form2" name="form2" method="post" action="">
<a href="dataeq.php">ข้อมูลอุปกรณ์</a>
</form></td>
</tr>
<tr>
<td align="center"><form id="form3" name="form3" method="post" action="crstaff.php">
<input type="submit" name="button3" id="button3" value="แก้ไขข้อมูลพนักงาน" />
</form></td>
<td align="center"><form id="form4" name="form4" method="post" action="">
<input type="submit" name="button4" id="button4" value="ดูใบแจ้งซ่อม" />
</form></td>
</tr>
<tr>
<td colspan="2" align="center"><form id="form5" name="form5" method="post" action="">
<a href="staff_logout.php"><button>ออกจากระบบ</button>
</a>
<p> </p>
<p><a href="staff_logout.php"> </a></p>
</form>
<p>
<?
require_once("phpAuthMySQLCheck.php");
?>
<?php
echo "<center><h1>Welcome ".$_SESSION["strUser"]." </h1><br><br><h2>กำลังเข้าใช้งาน</h2></center>"
?>
<a href="phpAuthenticationMySQL2.php">กำลังเข้าใช้งาน</a></p></td>
</tr>
</table>
</body>
</html>
ไฟล์ phpAuthMySQLCheck.php โค็ดauthentic
Code (PHP)
<?
session_start();
function fncAuthentication() {
header('WWW-Authenticate: Basic realm="localhost"');
header("HTTP/1.0 401 Unauthorized");
exit;
}
//*** Check user ***//
if (trim($_SERVER['PHP_AUTH_USER'])!= "" and trim($_SERVER['PHP_AUTH_PW']) != "")
{
mysql_connect("localhost","root","root");
mysql_select_db("pj");
$strSQL = "SELECT * FROM user WHERE User = '".trim($_SERVER['PHP_AUTH_USER'])."'
and Password = '".trim($_SERVER['PHP_AUTH_PW'])."'";
$objQuery = mysql_query($strSQL);
if(mysql_fetch_array($objQuery))
{
$_SESSION["strUser"] = $_SERVER['PHP_AUTH_USER'];
$_SESSION["strPass"] = $_SERVER['PHP_AUTH_PW'];
}
mysql_close();
}
//*** Session ***//
if(trim($_SESSION["strUser"])=="" or trim($_SESSION["strPass"])=="")
{
fncAuthentication();
exit();
}
?>
error ที่เจอ
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\pj\selec_staff.php:6) in C:\AppServ\www\pj\phpAuthMySQLCheck.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\pj\selec_staff.php:6) in C:\AppServ\www\pj\phpAuthMySQLCheck.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\pj\selec_staff.php:6) in C:\AppServ\www\pj\phpAuthMySQLCheck.php on line 5
ดาต้าเบสที่เชื่อมต่อ ชื่อ pj ตาราง user
Code (SQL)
ฐานข้อมูล: `pj`
--
-- --------------------------------------------------------
--
-- โครงสร้างตาราง `user`
--
CREATE TABLE `user` (
`id_staff` int(20) NOT NULL auto_increment,
`password` varchar(20) NOT NULL,
`name_staff` varchar(30) NOT NULL,
`lastname_staff` varchar(30) NOT NULL,
`email_staff` varchar(30) NOT NULL,
`tel_staff` varchar(15) NOT NULL,
`user` varchar(20) NOT NULL,
PRIMARY KEY (`id_staff`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- dump ตาราง `user`
--
INSERT INTO `user` VALUES (2, '1111', '1111', '1111', '1111', '1111', '1111');
ขอบคุณครับ
Tag : PHP, MySQL, HTML/CSS
|
|
 |
 |
 |
 |
Date :
2013-01-24 01:09:44 |
By :
plomplam.2 |
View :
838 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |