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 > ดูโค๊ดล็อคอินให้ทีครับ ต้องการให้ใช้งานที่ไฟล์ main .php ได้เฉพาะที่ล็อคอินที่แล้วเท่านั้น



 

ดูโค๊ดล็อคอินให้ทีครับ ต้องการให้ใช้งานที่ไฟล์ main .php ได้เฉพาะที่ล็อคอินที่แล้วเท่านั้น

 



Topic : 040369



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



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




ต้องการให้ใช้งานที่ไฟล์ main .php ได้เฉพาะที่ล็อคอินที่แล้วเท่านั้น
ถ้ายังไม่ล็อคอินให้เข้าที่หน้า index เท่านั้น ตอนนี้มันเข้าได้ทุกหน้า

ไฟล์ index.php ครับ

Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
include"config.php";

?>
<style type="text/css">
<!--
body {
	background-color: #FFFF99;
	margin-top: 0px;
}
-->
</style><form name="form1" method="post" action="index.php">
  <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <th height="29" align="center" bgcolor="#FFFF99" scope="col"><table width="1000" border="1" cellpadding="0" cellspacing="0">
        <tr>
          <th height="29" align="center" bgcolor="#FFFF99" scope="col"><table width="600" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <th height="29" align="center" bgcolor="#FFFF99" scope="col"><img src="images/naitam-banner-x-045 copy.jpg" width="1000" height="200" /></th>
            </tr>
          </table>
          <table width="600" border="0">
            <tr>
              <th height="92" align="center" valign="top" bgcolor="#FFFF99" scope="col"><table width="600" border="0">
                <tr>
                  <th align="left" bgcolor="#FFFF99" scope="col"><div align="center">ยินดีต้อนรับสู่ระบบจัดการร้านค้า</div></th>
                </tr>
              </table>
                <table width="600" border="0" align="right">
                <tr>
                  <th align="center" scope="col"><div align="center"><img src="images/adim.png" width="48" height="48" /></div></th>
                </tr>
                <tr>
                  <td align="center"><div align="center">ท่านผู้ดูแลระบบสามารถล็อกอินได้ที่นี่ </div></td>
                </tr>
              </table>
                </th>
            </tr>
          </table>
            <table width="600" border="0">
              <tr>
                <th align="center" bgcolor="#FFFF99" scope="col"><table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="78" height="30" align="left" valign="top">Username:</td>
                      <td width="106" align="left" valign="top"><label>
                        <input type="text" name="username" id="username" />
                      </label></td>
                    </tr>
                    <tr>
                      <td align="left" valign="top">Password:</td>
                      <td><label>
                        <input type="password" name="password" id="password" />
                      </label></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td><label></label></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td><input type="submit" name="button2" id="button2" value="ตกลง" />
                          <label>
                          <input type="reset" name="Reset" id="button" value="ยกเลิก" />
                        </label></td>
                    </tr>
                </table></th>
              </tr>
            </table>
            <table width="600" border="0">
              <tr>
                <th height="29" align="center" bgcolor="#FFFF99" scope="col">&nbsp;</th>
              </tr>
            </table></th>
        </tr>
      </table></th>
    </tr>
  </table>
<p>&nbsp;</p>
        </th>
        </tr>
        </table>
</form>
<?		
			$sql = "SELECT * FROM `user_login` WHERE `user_log` = '$username' AND `pass_log` = '$password'"; 
						
			$dbquery = mysql_db_query($dbname,$sql)or die(เชื่อมต่อฐานข้อมูลผิดพลาด);
			$num_rows = mysql_num_rows($dbquery);
			
								for ($i=1;$i<=$num_rows;$i++){
								$result = mysql_fetch_array($dbquery);
								$user_log = $result[user_log];
								$pass_log = $result[pass_log];
								$name = $result[name];
								$sername = $result[$sername];
								echo"$user_log,$pass_log,$name,$name";
								
								$_SESSION['loginstatus'] = true;
								$_SESSION['name'] = $emp_name;
								$_SESSION['sername'] = $emp_sername;
								$_SESSION['pro_name'] = $pro_sername;
								$_SESSION['type_id'] = $type_id;
								
								echo"<meta http-equiv=\"refresh\" content=\"0;url=main.php\">";  
								echo"$name $sername";
								exit(0);
								}
								
				
                    
                    
			



?>










ตัวนี้ไฟล์ main.php


Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html >
<style type="text/css">
<!--
body {
	margin-top: 0px;
	background-image: url(images/1bgside.gif);
}
-->
</style>



<body>
<table width="1200" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th height="488" align="center" valign="top" bgcolor="#FFFFFF" scope="col"><table width="800" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <th width="810" height="36" align="left" valign="top" scope="col"><img src="images/naitam-banner-x-045 copy.jpg" width="1200" height="200" /></th>
      </tr>
    </table>      
      <div align="left"></div>
      <div align="right"></div>
      <table width="172" border="0" align="left" cellpadding="0" cellspacing="0">
        <tr>
          <th width="172" bgcolor="#CC99CC" scope="col">เมนูหลัก</th>
        </tr>
        <tr>
          <td valign="middle" bgcolor="#C6E776"><a href="main.php?option=employee">พนักงาน</a></td>
        </tr>
        <tr>
          <td bgcolor="#C6E776"><a href="main.php?option=product">สินค้า</a></td>
        </tr>
        <tr>
          <td bgcolor="#C6E776"><a href="main.php?option=customer">ลูกค้า</a></td>
        </tr>
        <tr>
          <td bgcolor="#C6E776"><a href="main.php?option=color">สี</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">ประเภทสินค้า</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
         <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
         <tr>
          <td bgcolor="#CC99CC">ลิ้งเพื่อนบ้าน</td>
        </tr>
         <tr>
          <td bgcolor="#C6E776"><a href="https://www.thaicreate.com" target="blank" title="PHP,ASP,ASP.NET,VB.NET,C# Tutorials"> . PHP ThaiCreate.Com</a></td>
        </tr>
         <tr>
          <td bgcolor="#C6E776"><a href="main.php?option=checkpost">ตรวจสอบพัสดุ</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr><tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
        <tr>
          <th width="172" bgcolor="#CC99CC" scope="col">เกี่ยวกับระบบ</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">เปลี่ยนรหัสผ่าน</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#C6E776"><a href="logout.php">ออกจากระบบ</a></td>
        </tr>
      </table><?
		if(!isset($_REQUEST['option'])) {
		
				echo"ยินดีต้อนรับคุณ ".$_SESSION['name']." ".$_SESSION['sername']."  เข้าสู่ระบบการบริหารจัดการร้านค้า";
		
		}else{
		
       			include($_REQUEST['option'] . ".php"); 
		
		}
		
		?></th>
  </tr>
</table>

</body>
</html>





Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-03-15 15:37:58 By : khammool View : 1306 Reply : 7
 

 

No. 1

Guest


รบกวนโทรมาคุยกันนะครับ

ผมไม่มีเวลาตอบในนี้ให้นะครับ

[email protected]






Date : 2010-03-15 16:42:36 By : เสือ
 


 

No. 2



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



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


ไม่มีเวลาตอบในบอร์ดแต่มีเวลาคุยโทรศัพท์
Date : 2010-03-16 09:11:27 By : naskw
 

 

No. 3



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



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

เอาโค๊ดนี้ไปใส่ไว้บนสุดของเพจ main.php หรือหน้าอื่นๆที่จะให้เข้าได้เฉพาะตอนล๊อกอินแล้ว

Code
<?php
session_start();
if($_SESSION['loginstatus'] != true)
{ header("Location: index.php"); }
?>

Date : 2010-03-16 10:01:36 By : iamatomix
 


 

No. 4



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



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


ต้องแก้ไขอะไรหรือเปล่าครับ
Date : 2010-03-16 12:19:42 By : khammool
 


 

No. 5



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



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


ตามความเห็นที่ 3 เลยครับ
Date : 2010-03-16 12:43:46 By : naskw
 


 

No. 6

Guest


$sql = "SELECT * FROM `user_login` WHERE `user_log` = '$username' AND `pass_log` = '$password'";
086.
087. $dbquery = mysql_db_query($dbname,$sql)or die(เชื่อมต่อฐานข้อมูลผิดพลาด);
088. $num_rows = mysql_num_rows($dbquery);
089.
090. for ($i=1;$i<=$num_rows;$i++){
091. $result = mysql_fetch_array($dbquery);
092. $user_log = $result[user_log];
093. $pass_log = $result[pass_log];
094. $name = $result[name];
095. $sername = $result[$sername];
096. echo"$user_log,$pass_log,$name,$name";
097.
098. $_SESSION['loginstatus'] = true;
099. $_SESSION['name'] = $emp_name;
100. $_SESSION['sername'] = $emp_sername;
101. $_SESSION['pro_name'] = $pro_sername;
102. $_SESSION['type_id'] = $type_id;
103.
104. echo"<meta http-equiv=\"refresh\" content=\"0;url=main.php&a==1\">";
105. echo"$name $sername";
106. exit(0);


index.php ตรง a==1 ส่งค่าไปด้วย

แล้ว

mail.php

บนสุดหรือบรรทัดแรกพิมพ์

<? if(a==1){ ?>

ล่างสุดหรือบรรทัดล่างสุดพิมพ์

<? } ?>


ok ไหมครับ
Date : 2012-09-23 15:50:22 By : thej
 


 

No. 7

Guest


ผมมาใหม่ฝากเนื้อฝากตัวด้วย
Date : 2012-09-23 15:53:00 By : thej
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ดูโค๊ดล็อคอินให้ทีครับ ต้องการให้ใช้งานที่ไฟล์ main .php ได้เฉพาะที่ล็อคอินที่แล้วเท่านั้น
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 00
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 อัตราราคา คลิกที่นี่