Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยด้วยคับระบบ login ของผมมันเปลี่ยน แอคเคาท์เองอะคับทำไงดี ต้องแก้ยังไงคับ



 

ช่วยด้วยคับระบบ login ของผมมันเปลี่ยน แอคเคาท์เองอะคับทำไงดี ต้องแก้ยังไงคับ

 



Topic : 082519



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์




คือพอล็อคอินเข้าไปแล้วกดไปหน้าอื่นประมาน 4-5 หน้า มันก้อจะเปลี่ยน แอคเคาท์ให้เองอะคับ
แก้ยังไงดี ช่วยหน่อยนะคับจนปัญาจิงๆ

โค้ดเช็คล็อคอิน
Code (PHP)
<?php
session_start();
require_once "include/connectdb.php";
		$sql = "SELECT * FROM useradmin WHERE userid ='".$_POST[userid]."' and password='".$_POST[password]."'";
		$dbquery = mysql_db_query($db, $sql); 
		$num_rows = mysql_num_rows($dbquery);
		$rowLogin = mysql_fetch_array($dbquery);
		$redirect = $rowLogin[redirect];
		if($num_rows == 1){ 
		   if ($redirect == "ADMIN")
		   {
			$_SESSION['userid'] = $rowLogin['userid'];
			echo "<meta http-equiv='refresh' content='0;URL=AdminIndex.php'>";
		   }else if ($redirect == "ENDORSEE")
		   {
			$_SESSION['userid'] = $rowLogin['userid'];
			echo "<meta http-equiv='refresh' content='0;URL=HeadIndex.php'>";
			 }else if ($redirect == "STAFF")
		   {
			$_SESSION['userid'] = $rowLogin['userid'];
			echo "<meta http-equiv='refresh' content='0;URL=StaffIndex.php'>";
		   }else if ($redirect == "USER")
		   {
			$_SESSION['userid'] = $rowLogin['userid'];
			echo "<meta http-equiv='refresh' content='0;URL=UserIndex.php'>";
		   }
		}else{ 
			echo "<meta http-equiv='Content-Type' content='text/html; charset=tis-620' />";
			echo "<script language='javascript'>alert('ชื่อหรือรหัสผ่านไม่ถูกต้อง กรุณาตรวจสอบอีกครั้ง');</script>";
			echo "<meta http-equiv='refresh' content='0;URL=index.php'>";
		}
	
?>

-------------------------------------------------------------------------------------------------------------------------------------------------------
โค้ดส่วนที่ใช้เรียก

Code (PHP)
<?
@session_start();
ob_start();
$userid = $_SESSION["userid"];
if(empty($userid))
{
echo "<script>alert('หน้านี้จำกัดเฉพาะผู้ที่เกี่ยวข้องในระบบเท่านั้น');history.back();</script>";
exit();
}
require_once "include/tdate.php";
require_once "include/connectdb.php";

						  $sql="select * from useradmin where userid ='$userid'";
						  $db_query=mysql_db_query($db,$sql);
						  $result=mysql_fetch_array($db_query);
						  $id=$result[id];
						  $userid=$result[userid];
						  $adminname=$result[name];
						  $departid=$result[departid];
						  $password=$result[password];
?>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-08-18 14:27:21 By : golfharo View : 998 Reply : 8
 

 

No. 1



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


เปลี่ยนยังไงครับ งง ถ้าคุณไม่เขียนให้มันเปลี่ยน มันไม่เปลี่ยนเองแน่นอน






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-18 15:16:29 By : ikikkok
 


 

No. 2



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์


ผมก้องงเหมือนกันคับ
พอเข้าไปประมาน4-5หน้ามันเปลี่ยนเอง ผมติดตรงนี้มาสองวันและ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-18 15:57:13 By : golfharo
 

 

No. 3



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์


ผมรู้แล้วคับมันเป็นกับหน้านี้
พอเข้าหน้านี้แล้วพอจะไปหน้าอื่นมันจะเปลี่ยนแอคเคาท์หรือออกจากระบบเองอัตโนมัติ
ช่วยดูให้หน่อยคับ

Code (PHP)
<?
@session_start();
ob_start();
$userid = $_SESSION["userid"];
if(empty($userid)) 
{
echo "<script>alert('หน้านี้จำกัดเฉพาะผู้ที่เกี่ยวข้องในระบบเท่านั้น');history.back();</script>";
exit();
}
require_once "include/tdate.php";
require_once "include/connectdb.php";

						  $sql="select * from useradmin where userid='$userid'";
						  $db_query=mysql_db_query($db,$sql);
						  $result=mysql_fetch_array($db_query);
						  $id=$result[id];
						  $userid=$result[userid];
						  $adminname=$result[name];
						  $departid=$result[departid];
						  $password=$result[password];
?>
<html>
<head>
<title>ระบบการลาของฝ่ายผลิตในบริษัทภูไพรจำกัด</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">

<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
#apDiv1 {
	position:absolute;
	left:1023px;
	top:393px;
	width:41px;
	height:23px;
	z-index:1;
}
-->
</style>
</head>
<body bgcolor="#ffffff">
<div id="apDiv1">
  <input name="btnPrint" type="button" id="btnPrint" value="Print" onClick="JavaScript:this.style.display='none';printpr();">
</div>
<br>
<div align="center"><br>
  <table border="0" cellpadding="0" cellspacing="0" width="945">
    <tr>
      <td><div align="right"><font color="#993333" size="2"><img src="images/icon_man.gif" width="15" height="15"> 
          <font color="#333333">ยินดีต้อนรับคุณ</font></font><font color="#FF0000" size="2"> 
          <? echo "<u>$adminname</u>"; ?> <font color="#333333">เข้าใช้งานในระบบ<br>
          <a href="Profiles.php">ข้อมูลส่วนตัว</a> | <a href="Logout.php"><font color="#990000">ออกจากระบบ</font></a></font></font> 
        </div></td>
    </tr>
    <tr> 
      <td><img name="bx_r1_c1" src="images/ff.jpg" width="945" height="28" border="0" alt=""></td>
    </tr>
    <tr> 
      <td background="images/bx_r2_c1.jpg"><div align="center"> 
          <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td><table width="688" border="0" align="center" cellpadding="1" cellspacing="1">
                  <tr> 
                    <td width="184">&nbsp;</td>
                    <td width="1">&nbsp;</td>
                    <td width="223"><div align="center"><a href="Emp.php"><img src="images/hh1.jpg" width="117" height="71" border="0"></a></div></td>
                    <td width="23">&nbsp;</td>
                    <td width="425"><div align="center"><a href="Leave_Manage.php"><img src="images/cus2.jpg" width="117" height="71" border="0"></a></div></td>
                    <td width="17">&nbsp;</td>
                    <td width="232"><div align="center"><a href="Leave_Report1.php"><img src="images/cus3.jpg" width="117" height="71" border="0"></a></div></td>
                    <td width="184">&nbsp;</td>
                  </tr>
                </table>
                
              </td>
            </tr>
            <tr> 
              <td><div align="center"><br>
                  <br>
                  <br>
                  <font color="#FF0000" size="2">** หมายเหตุ ในกรณีที่ <font color="#003366">รออนุมัติ 
                  </font>ท่านสามารถที่จะยกเลิกหากไม่ต้องการทำรายการลาในวันดังกล่าว</font><br>
                  <table width="90%" border="0" cellspacing="0" cellpadding="0">
                    <tr class="jobscss"> 
                      <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="1" cellpadding="1">
                          <tr> 
                            <td bgcolor="#333333"><table width="842" border="0" cellspacing="1" cellpadding="1">
                                <tr bgcolor="#FFFFCC"> 
                                  <td width="62"><div align="center"><font color="#990000" size="2"><strong>#</strong></font></div></td>
                                  <td width="99"><div align="center"><font color="#990000" size="2"><strong>ตั้งแต่วันที่</strong></font></div></td>
                                  <td width="91"><div align="center"><font color="#990000" size="2"><strong>ถึงวันที่</strong></font></div></td>
                                  <td width="81"><div align="center"><font color="#990000" size="2"><strong>จำนวนวัน</strong></font></div></td>
                                  <td width="258"><div align="center"><font color="#990000" size="2"><strong>หมายเหตุ</strong></font></div></td>
                                  <td width="141"><div align="center"><font color="#990000" size="2"><strong>วันที่ทำรายการ</strong></font></div></td>
                                  <td width="88"><div align="center"><font color="#990000" size="2"><strong>การอนุมัติ</strong></font></div></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table>
                        <?
$page = $_GET['page'];
$num = 1;
$select_type="select * from leavemanager order by id asc";
$query_select=mysql_query($select_type);
$num_rows=mysql_num_rows($query_select);

if($num_rows<1){
echo "<br><br><center><font color=#666666 face=tahoma size=2><b>ยังไม่มีการเพิ่มข้อมูลค่ะ</b></font></center>";
}else{
		$select="select * from leavemanager  order by id asc";
		$q_ry = mysql_query($select);
	 	$num_rows=mysql_num_rows($q_ry);
  		$pagesize=20;
		$rt=$num_rows%$pagesize;
		if($rt!=0)
			{
				$totalpage=floor($num_rows/$pagesize)+1;
			}
		else
			{
				$totalpage=floor($num_rows/$pagesize);
				$toppic_id=1;
			}
		if(empty($page))
			{
				$page=1;
			}
		mysql_free_result($q_ry);
		$goto=($page-1)*$pagesize;
$sql_select_mem="Select * From leavemanager  order by id asc limit $goto,$pagesize";
		$fect=mysql_query($sql_select_mem);
		if(!$fect)
		{
		("ติดต่อฐานข้อมูลไม่ได้".mysql_error());
		exit;
		}

	  $bgcount=0;
	while($rows=mysql_fetch_array($fect))
	{
$idx =$rows['id'];
$userid  =$rows['userid'];
$leavetypeid =$rows['leavetypeid'];
$datefrom = $rows['datefrom'];
$dateto = $rows['dateto'];
$amountdate = $rows['amountdate'];
$comment = $rows['comment'];
$status = $rows['status'];
$dateregis = $rows['dateregis'];
$bgcount=$bgcount+1;
$bgmod=$bgcount%2;
if($bgmod==0){
	$bgcolor="#E1DFD7";
}else{
	$bgcolor="#FDFBF4";
}
	?>
                        <table width="100%" border="0" cellspacing="1" cellpadding="1">
                          <tr> 
                            <td bgcolor="#333333"><table width="842" border="0" cellspacing="1" cellpadding="1">
                                <tr bgcolor="#FFFFFF"> 
                                  <td width="62"><div align="center"><font color="#993300" size="2"><? echo "$num"; ?></font></div></td>
                                  <td width="99"><div align="center"><font color="#993300" size="2"><? echo "$datefrom"; ?></font></div></td>
                                  <td width="91"><div align="center"><font color="#993300" size="2"><? echo "$dateto"; ?></font></div></td>
                                  <td width="81"><div align="center"><font color="#993300" size="2"><? echo "$amountdate"; ?></font></div></td>
                                  <td width="258"><font color="#993300" size="2"><? echo "$comment"; ?></font></td>
                                  <td width="141"><div align="center"><font color="#993300" size="2"><? echo "$dateregis"; ?></font></div></td>
                                  <td width="88"><div align="center"> 
                                      <? 
								  if($status == "00000")
								  {
								  echo "<a href=ApprooveNow.php?ID=$idx><font size=2 color=#1157B6>รออนุมัติ</font></a>"; 
								  }else if($status == "11111")
								  {
								  echo "<font size=2 color=#ff0000>ไม่อนุมัติ</font>"; 
								  } else if($status == "22222")
								  {
								  echo "<font size=2 color=#000000><b>ยกเลิก</b></font>"; 
								  } else if($status == "99999")
								  {
								  echo "<font size=2 color=#107706><b>อนุมัติแล้ว</b></font>"; 
								  } 
								  ?>
                                    </div></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table>
                        <?
$num = $num+1;
}
}
?>
                      </td>
                    </tr>
                    <tr class="jobscss"> 
                      <td height="19">&nbsp;</td>
                    </tr>
                    <tr class="jobscss"> 
                      <td><strong><span class="maekhawtom"><font color="#990000" size="2">หน้าที่ 
                        :</font></span></strong> <font color="#999999" size="2"><span class="maekhawtom"> 
                        <? 
	for($i=1;$i<$page;$i++)
	{
	echo"[<a href='$PHP_SELF?page=$i'><font size=2 color='#000000'>$i</font></a>]";
	}
	echo"[<font size=2 color=#000000><b><font size=2 color='#FF00000'>$page</font></b></font>]";
	for($i=$page+1;$i<=$totalpage;$i++)
	{
	echo"[<a href='$PHP_SELF?page=$i'><font size=2 color='#000000'>$i</font></a>]";
	}
	?>
                        </span></font><font color="#FFFFFF" size="2"><span class="maekhawtom"> 
                        </span></font></td>
                    </tr>
                    <tr> 
                      <td><div align="center"></div></td>
                    </tr>
                  </table>
                  <br>
                  <br>
                </div></td>
            </tr>
          </table>
        </div></td>
    </tr>
    <tr> 
      <td><img name="bx_r3_c1" src="images/bx_r3_c1.jpg" width="945" height="9" border="0" alt=""></td>
    </tr>
  </table>
</div>
<script language="javascript">
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-18 16:32:08 By : golfharo
 


 

No. 4



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

ผมเคยเจอครับอาการนี้ ลองตรวจสอบเรื่อง ตัวแปลครับ เพราะผมเคยเจอเหมือนกันตอนเวลาเรากำหนด permission แล้วตัวแปลที่เราเขียนมันเปลี่ยนให้เราเองอัตโนมัตครับ ถ้าให้ชัวร์ผมว่าลองสังเกตุดูครับว่ามันเปลี่ยนที่ page ไหนทดสอบดูเลยครับกดไปที่หน้าเดิมซักหน้าล่ะ 4-5 ครัง ถ้ามันไม่เปลี่ยน user ก็ลองเปลี่ยนไปกดหน้าอื่นดูครับ สู้ๆ ครับผม
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-18 21:25:42 By : demonking
 


 

No. 5



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 4 เขียนโดย : demonking เมื่อวันที่ 2012-08-18 21:25:42
รายละเอียดของการตอบ ::
เช็คแล้วคับมันเป็นหน้าที่อยุ่ตรงความคิดเห็นที่ 3 อะคับ
แต่ก้อยังไม่รุ้ว่าควรแก้ตรงจุดไหน

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-18 21:31:16 By : golfharo
 


 

No. 6



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์
Twitter Facebook

ลองเปลียนโค๊ด
Code (PHP)
$sql="select * from useradmin where userid='$userid'";
$db_query=mysql_db_query($db,$sql);
$result=mysql_fetch_array($db_query);
$id=$result[id];
$userid=$result[userid];
$adminname=$result[name];
$departid=$result[departid];
$password=$result[password];


มาใช้ session ก่อนนะครับ ตอน login ลองแก้ดูก่อนนะครับเผื่อได้ เอาในส่วนของโค๊ดตัวเก่าในหน้าที่มีปัญหาออกก่อน
Code (PHP)
<?php
session_start();
require_once "include/connectdb.php";
		$sql = "SELECT * FROM useradmin WHERE userid ='".$_POST[userid]."' and password='".$_POST[password]."'";
		$dbquery = mysql_db_query($db, $sql); 
		$num_rows = mysql_num_rows($dbquery);
		$rowLogin = mysql_fetch_array($dbquery);
		$redirect = $rowLogin[redirect];
		if($num_rows == 1){ 
			$_SESSION = array('id'=>$rowLogin['id'],'userid'=>$rowLogin['userid'],'name'=>$rowLogin['name'],'departid'=>$rowLogin['departid'],'redirect'=>$rowLogin['redirect']); //ส่วนของ password ไม่น่าจะจำเป็นนะครับเพื่อความปลอดภัย
		
			switch($_SESSION['redirect']){
				case ADMIN:
					echo "<meta http-equiv='refresh' content='0;URL=AdminIndex.php'>";
				break;
				case ENDORSEE:
					echo "<meta http-equiv='refresh' content='0;URL=HeadIndex.php'>";
				break;
				case USER:
					echo "<meta http-equiv='refresh' content='0;URL=UserIndex.php'>";
				break;
				case STAFF:			
					echo "<meta http-equiv='refresh' content='0;URL=StaffIndex.php'>";
				break;
				default:
					echo "<meta http-equiv='Content-Type' content='text/html; charset=tis-620' />";
					echo "<script language='javascript'>alert('ชื่อหรือรหัสผ่านไม่ถูกต้อง กรุณาตรวจสอบอีกครั้ง');</script>";
					echo "<meta http-equiv='refresh' content='0;URL=index.php'>";
				break;
			}
		}
?>

เวลาเรียกใช้ก็ $_SESSION['userid'] หรือ $_SESSION['name'] น่าจะง่ายกว่านะครับถ้าเอามันเข้าไปใน session เลย

พอเวลาเรา logout ก็ให้ใช้ก็ตามนี้ครับ
https://www.thaicreate.com/php/forum/031531.html


ประวัติการแก้ไข
2012-08-19 05:55:39
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-19 05:54:42 By : demonking
 


 

No. 7



โพสกระทู้ ( 45 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณคับ
แต่ยังเป็นเหมือนเดิมคับ
พอเข้าหน้านั้นแล้วไปกดเข้าหน้าอื่นแล้วมันจะเปลี่ยนแอคเคาท์ให้เอง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-19 15:15:51 By : golfharo
 


 

No. 8



โพสกระทู้ ( 41 )
บทความ ( 0 )



สถานะออฟไลน์


ลองเปลี่ยนตัว แปร ของ session กับ post ให้เป็นคนละชื่อกันครับ

เช่น

$ses_userid=$_SESSION['ses_userid'];

$pos_userid=$_POST['pos_userid'];

$row_userid =$rows['userid'];
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-19 16:24:23 By : nontadech
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยคับระบบ login ของผมมันเปลี่ยน แอคเคาท์เองอะคับทำไงดี ต้องแก้ยังไงคับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่