|
|
|
พี่ ครับ คือ ผม อยาก จะ ให้ มัน เอา username และ password บอ หน้า login name |
|
|
|
|
|
|
|
คือผมสามารถเอา ชื่อที่ คนใช่ login มาแสดง ได้ แล้ว แค่ ตอนนี้ ครับ ผม อยากจะ ให้ มัน เป็น value เพื่อ ที่ ผม จะ ได้เอา ไปตรวจ สอบ ใน data base อ่ะ ครับ ผม ควร จะ ทำ อย่างไง ดี ครับ ช่วย บอกที่ได้ไหม ครับ นี้ คือ โค๊ดทั้ง หมด ที่เกี่ยวข้องน่ะครับ
หน้า formlogin
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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<form name="from1" method="post" action="checkuser.php">
<table width="240" border="0" align="center">
<tr>
<td colspan=2>Please login</td>
</tr>
<tr>
<td width="86"> Username:<td><input type="text" name="username" />
</tr>
<tr>
<td>Password:</td>
<td><input name="pw" type="password" /></td>
</tr>
<tr>
<td colspan="2"><div align="center"><input type="submit" name="Submit" value="Login" /></div></td>
</tr>
</table>
</form>
<form id="form1" name="form2" method="post" action="register.php">
<label for="Register"> </label>
<input type="submit" name="Register" id="Register" value="Register" />
</form>
</body>
</html>
หน้า chenck user
Code (PHP)
<?
$host = "127.0.0.1";
$user = "root";
$password = "12345";
$dbname = "rimes1";
mysql_connect($host,$user,$password) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
$sql = " SELECT * FROM user_table WHERE username='". $_POST['username']. "' AND password = '". $_POST['pw']. "'";
$dbquery = mysql_db_query($dbname,$sql);
$row = mysql_fetch_array($dbquery);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1 && $row[9]==0) {
session_register("loginname");
$_SESSION['loginname'] = $_POST['username'] ;
session_register("password");
echo "<script>alert('patience.....');window.location='main.php';</script>";
}
else if($num_rows==1 && $row[9]==1) {
session_register("loginname");
$_SESSION['loginname'] = $_POST['pw'];
session_register("password");
echo "<script>alert('Goto AdminPage.....');window.location='admin.php';</script>";
}
else {
echo "<script>alert('Cannot Enter'),window.location = 'formlogin';</script>";
}
?>
หน้า main
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
echo $_SESSION['loginname'];
?>
<!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=windows-874" />
<title>Untitled Document</title>
</head>
<h1>Main</h1>
<body>
<h1>Main</h1>
<form action="checkuser.php">
<?
echo $_SESSION['loginname'];
/* echo $_SESSION['loginname'];
echo $_SESSION['loginname'];
echo $_SESSION['loginname'];
echo $_SESSION['loginname']; */
echo $_GET['logname'];
?>
</form>
<p><a href="insertandedit.php">Insert And edit </a></p>
<p><a href="selectbynamecom.php">Search</a></p>
<p><a href="formlogin.php">backtologin</a></p>
<?
echo $_GET['logname'];
echo $_GET['logname'];
echo $_GET['logname'];
echo $_GET['logname'];
?>
</body>
</html>
หน้า insertandedit
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
echo $_SESSION['loginname'];
?>
<!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
body { font-size: 12px;}
legend {font-size:12px; font-weight:bold;color:#00F;}
</style>
</head><?
include "./include/connect1.php";
?>
<body>
<form id="form1" name="form1" method="post" action="insertandedit1.php">
<p> <strong>Employee Detail</strong></p>
<table width="782" height="44" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="font22">
<td width="778" valign="top"><table width="719" border="1" align="center" cellpadding="0" cellspacing="1">
<tr class="header24">
<td colspan="10" bgcolor="#F0F0F0"><div align="center" class="header">
<h3>Employee Detail</h3>
</div></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#CCCCCC" class="font22">
<td width="173" align="center" class="font14-5"><div align="center">name</div></td>
<td width="295" align="center" class="font14-5"><div align="center">lname</div></td>
<td width="273" align="center" class="font14-5"><div align="center">position</div></td>
<td width="273" align="center" class="font14-5"><div align="center">Grade and step</div></td>
</tr>
<?
/* $dte1 = $_REQUEST['dte1']; */
// $dte2 = $_REQUEST['dte2'];
/* $start = $dte1; */
// $end = $dte2;
$sql_seleect = "select distinct u.user_id,fname,lname,position,gradeandstep from user_table u,time_sheet_table t where u.user_id = t.user_id ";
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['fname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['lname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['position']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['gradeandstep']; ?></div></td>
</tr>
<? }
$test = "2010-11-21 10:00:00";
$peices=explode(" ",$test);
echo $pieces[0];
echo "\n";
echo $pieces[1];
?>
</table></td>
</tr>
</table>
<p> </p>
<hr />
<p><storng>
<center>
<p>Day :
<input type="text" name="day" id="day" />
</p>
<p>Monday- Sunday</p>
</center>
<center><fieldset>
<legend>Nomal Time:</legend>
<p>Date:
<input type="text" name="n_date" id="n_date" />
</p>
<p>YYYY-MM-DD<br />
<br />
Time in:
<input type="text" name="n_timein" id="n_timein" />
</p>
<p>HH:MM:SS</p>
<p>
Time out :
<input type="text" name="n_timeout" id="n_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center>
</p><hr />
<p><center><fieldset>
<legend>Shift Time</legend>
<p>Date:
<input type="text" name="s_date_timein" id="s_date_timein" />
</p>
<p>YYYY-MM-DD <br />
Time in:
<input type="text" name="s_timein" id="s_timein" />
</p>
<p>HH:MM:SS</p>
<p>Date:
<input type="text" name="s_date_time_out" id="s_date_time_out" />
</p>
<p>YYYY-MM-DD</p>
<p>
Time out :
<input type="text" name="s_timeout" id="s_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center></p><hr /><center><fieldset>
<legend><font size="4">Key Accomplishments</font></legend>
<p>
<textarea name="detail" id="detail" cols="45" rows="5"></textarea>
</p>
</fieldset></center></p>
<input type="submit" name="button" id="Insert" value="Insert" />
</form>
</body>
</html>
ควรทำยังไงดี ครับ ถ้ามีcode ให้ดู ก้อ จะ ดี มากๆ เลย ครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-04-19 11:46:53 |
By :
macro |
View :
889 |
Reply :
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ๋อ อันนั้น ได่แล้วครับผมต้องการ ให้มันแสดงในทุกหน้่อ่ะครับจะต้องทำยังไง
|
|
|
|
|
Date :
2011-04-19 13:28:28 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ประกาศเป็น Session ครับ แล้วเอามา Echo ได้ทุกหน้า
|
|
|
|
|
Date :
2011-04-19 13:34:33 |
By :
ParotZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือ ผม ต้องการ ให้ ไอ้ ค่า ในsession อ่ะ ครับ นำมาตรวจสอบในดาต้าเบสอ่ะครับ จะเป็นไป ได้ ไหม ครับ
|
|
|
|
|
Date :
2011-04-19 13:36:54 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้สิครับ
|
|
|
|
|
Date :
2011-04-19 13:45:38 |
By :
ParotZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำอย่างไง อ่ะ ครับ ขอดู ตัวอย่างหน่อยได้ไหม ครับ เอา แปป ง่าย ๆ ก่อ นน่ะ ครนับ
|
|
|
|
|
Date :
2011-04-19 13:48:13 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยกตัวอย่างว่ามีการประกาศ Session ไว้เมื่อตอน logon สำเร็จ
Code (PHP)
<?
## Promote Session ##
session_start();
$_SESSION['UserName'] = "ไตรภูมิ";
?>
หน้าอื่นๆก็รับค่า Session มาตรวจสอบข้อมูลใน Database
Code (PHP)
<?
## Get Session ##
session_start();
$UserName = $_SESSION["UserName"];
## User Info ##
$sql = "SELECT * FROM user WHERE UserName='$UserName'";
$result = mssql_query($sql);
$numrow = mssql_num_rows($result);
$value = mssql_fetch_array($result);
$Gender = $value["Gender"];
$Age = $value["Age"];
?>
|
ประวัติการแก้ไข 2011-04-19 13:57:20
|
|
|
|
Date :
2011-04-19 13:56:00 |
By :
ParotZ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้ว ถ้า ผม ทำ คน ล่ะหน้า จะได้ไหม ครับ จะส่งไปหน้าอื่นอ่ะครับ อย่างงี้ ได้ไหม ครับ
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
echo $_SESSION['loginname'];
echo $_SESSION['pw'];
$name = $_SESSION['loginname'];
?>
<!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
body { font-size: 12px;}
legend {font-size:12px; font-weight:bold;color:#00F;}
</style>
</head><?
include "./include/connect1.php";
?>
<body>
<form id="form1" name="form1" method="" action="insertandedit1.php">
<p> <strong>Employee Detail</strong></p>
<table width="782" height="44" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="font22">
<td width="778" valign="top"><table width="719" border="1" align="center" cellpadding="0" cellspacing="1">
<tr class="header24">
<td colspan="10" bgcolor="#F0F0F0"><div align="center" class="header">
<h3>Employee Detail</h3>
</div></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#CCCCCC" class="font22">
<td width="173" align="center" class="font14-5"><div align="center">name</div></td>
<td width="295" align="center" class="font14-5"><div align="center">lname</div></td>
<td width="273" align="center" class="font14-5"><div align="center">position</div></td>
<td width="273" align="center" class="font14-5"><div align="center">Grade and step</div></td>
</tr>
<?
/* $dte1 = $_REQUEST['dte1']; */
// $dte2 = $_REQUEST['dte2'];
/* $start = $dte1; */
// $end = $dte2;
$sql_seleect = "select distinct u.user_id,fname,lname,position,gradeandstep
from user_table u,time_sheet_table t
where u.user_id = t.user_id and username = '$name' "; /* ตรงนี้เขียนอย่างงี้ได้ไหม ครับ */
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['fname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['lname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['position']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['gradeandstep']; ?></div></td>
</tr>
<? }
?>
</table></td>
</tr>
</table>
<p> </p>
<hr />
<p><storng>
<center>
<p>Day :
<input type="text" name="day" id="day" />
</p>
<p>Monday- Sunday</p>
</center>
<center><fieldset>
<legend>Nomal Time:</legend>
<p>Date:
<input type="text" name="n_date" id="n_date" />
</p>
<p>YYYY-MM-DD<br />
<br />
Time in:
<input type="text" name="n_timein" id="n_timein" />
</p>
<p>HH:MM:SS</p>
<p>
Time out :
<input type="text" name="n_timeout" id="n_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center>
</p><hr />
<p><center><fieldset>
<legend>Shift Time</legend>
<p>Date:
<input type="text" name="s_date_timein" id="s_date_timein" />
</p>
<p>YYYY-MM-DD <br />
Time in:
<input type="text" name="s_timein" id="s_timein" />
</p>
<p>HH:MM:SS</p>
<p>Date:
<input type="text" name="s_date_time_out" id="s_date_time_out" />
</p>
<p>YYYY-MM-DD</p>
<p>
Time out :
<input type="text" name="s_timeout" id="s_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center></p><hr /><center><fieldset>
<legend><font size="4">Key Accomplishments</font></legend>
<p>
<textarea name="detail" id="detail" cols="45" rows="5"></textarea>
</p>
</fieldset></center></p>
<input type="submit" name="button" id="Insert" value="Insert" />
<h1><? echo $name ; ?></h1>
<? echo nl2br("");?>
<h1><? echo $name ; ?></h1>
<a href="formlogin.php">กลับหน้า Login</a>
</form>
</body>
</html>
|
ประวัติการแก้ไข 2011-04-19 14:18:51
|
|
|
|
Date :
2011-04-19 14:13:30 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วคร๊าบบบบบบบบบบบบบบบบบบ ขอบคุณมากน่ะครับคุณ ParotZ
|
|
|
|
|
Date :
2011-04-19 14:37:36 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|