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,028

HOME > PHP > PHP Forum > อยากทราบว่า เราสามารถกำหนดสิทธิ์ผู้ใช้งาน โดยใช้ radio button ได้ไหมครับ



 

อยากทราบว่า เราสามารถกำหนดสิทธิ์ผู้ใช้งาน โดยใช้ radio button ได้ไหมครับ

 



Topic : 116562



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



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




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>


<script language="javascript">
	function show_radio(id) {
	if(id == 'admin') { 
	document.getElementById("teacher").style.display = "none";
	document.getElementById("std").style.display = "none";	
		
	}if(id == 'user') { 
	document.getElementById("teacher").style.display = "none";
	document.getElementById("std").style.display = "none";
		
	}if(id == 'teacher') { 
	document.getElementById("teacher").style.display = "";
	document.getElementById("std").style.display = "none";
	
	} else if(id == 'std') {
	document.getElementById("teacher").style.display = "none";
	document.getElementById("std").style.display = "";
	}
}
</script>

</head>

<body>
<table width="900" height="166" id="container">
<tr><td height="56" colspan="3" align="left" id="header"><h1>เพิ่มผู้ใช้งาน</h1></td></tr>
<tr>
	<td id="left-side">&nbsp;</td>
    <td id="content">
	<form method="post" name="register" action="save_register.php">
      <div id="top">กรุณากรอกข้อมูล</div>
      <p>        
        <input type="text" name="username" id="username" placeholder="ชื่อผู้ใช้"><br>
        <input type="password" name="pswd" id="pswd" placeholder="รหัสผ่าน"><br>
        <input type="password" name="pswd2" id="pswd2" placeholder="ยืนยันรหัสผ่าน"><br>
        <input type="text" name="name" id="name" placeholder="ชื่อ"><br>
        <input type="text" name="lastname" id="lastname" placeholder="นามสกุล"><br>
        <input type="text" name="tel" id="tel" placeholder="เบอร์โทรศัพท์"><br>
        <input type="text" name="mail" id="mail" placeholder="อีเมล์">
      </p>
      <fieldset id="radio">
        <legend>เลือกกลุ่มผู้ใช้งาน</legend>
        <p>        
          <label>
            <input name="radiochoice" type="radio" id="radiochoice_0" value="admin" checked="CHECKED" onClick="show_radio(this.value);">ผู้ดูแลระบบ</label>
            
          <label>
            <input type="radio" name="radiochoice" value="user" id="radiochoice_1" onClick="show_radio(this.value);">เจ้าหน้าที่สำนักงาน</label>
            
          <br>
          <label>
            <input type="radio" name="radiochoice" value="teacher" id="radiochoice_2" onClick="show_radio(this.value);">อาจารย์</label>&nbsp; &nbsp; &nbsp;
            
          <label>
            <input type="radio" name="radiochoice" value="std" id="radiochoice_3" onClick="show_radio(this.value);">นักศึกษา</label>
            <br>
            <label for="select"></label>
                <?php include 'connect.php'?>

						<select name="select" id="teacher" style="display:none"; onchange="">
						<option value="">- กรุณาเลือก -</option>
						<?php 
							$query_list=mysql_query("select * from department order by de_name"); 
							while ($sl <mysql_num_rows($query_list)) {
							$arrL=mysql_fetch_array($query_list);	  
						?>
							<option value="<?php echo $arrL['de_name'];?>"><?php echo $arrL['de_name'];?></option>
						<?php
							$sl++;
						}
						 ?>
					</select>

			<label for="select2"></label>
				 <?php include 'connect.php'?>
				  
				 		<select name="select" id="std" style="display:none"; onchange="">
						<option value="">- กรุณาเลือก -</option>
						<?php 
							$query_list=mysql_query("select * from department order by de_name"); 
							while ($sl2 <mysql_num_rows($query_list)) {
							$arrL=mysql_fetch_array($query_list);	  
						?>
							<option value="<?php echo $arrL['de_name'];?>"><?php echo $arrL['de_name'];?></option>
						<?php
							$sl2++;
						}
						 ?>
					</select>                                  
        </p>
        
      </fieldset>
      
      <div id="bottom">
        <button id="submit">ตกลง</button>
        <br class="clear">
    </div>
      <input type="hidden" name="MM_insert" value="register">
    </form></td>
    <td id="right-side">
 	<br><br><br><br><br><br>
    </td>
</tr>
</table>
</body>
</html>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-05-18 04:01:57 By : Tcomcomsci View : 690 Reply : 2
 

 

No. 1



โพสกระทู้ ( 9,559 )
บทความ ( 2 )



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


การกำหนด trustee ใน script แบบนี้ไม่ดีครับ เขาแก้ไข ฝั่ง client ได้ง่ายๆ ทำให้เข้าใจวิธีการเขียน ทำให้ hack ได้ง่ายขึ้น

Code (JavaScript)
<script language="javascript">
function show_radio(id) {
if(id == 'admin') { 
document.getElementById("teacher").style.display = "none";
document.getElementById("std").style.display = "none";	

}if(id == 'user') { 
document.getElementById("teacher").style.display = "none";
document.getElementById("std").style.display = "none";

}if(id == 'teacher') { 
document.getElementById("teacher").style.display = "";
document.getElementById("std").style.display = "none";

} else if(id == 'std') {
document.getElementById("teacher").style.display = "none";
document.getElementById("std").style.display = "";
}
}
</script>


ตัวอย่าง ใช้ php ในการควบคุม
Code (PHP)
<?php
if( isAdmin ){
   echo "<div class='admin'>.....<'div>";
}elseif( isTeacher ){
   echo "<div class='teacher'>.....<'div>";
}else other. ......
?>

ไม่จำเป็นให้ client มีข้อมูลทุกอย่างที่ไม่ได้ใช้ ที่ง่ายที่สุด คือ ให้ include เป็น file
Code (PHP)
<?php
if( isAdmin ){
  include('home_admin.php');
}elseif( isTeacher ){
   include('home_teacher.php');
}else other. ......
?>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-05-18 09:05:22 By : Chaidhanan
 


 

No. 2



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



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


ขอบคุณสำหรับคำแนะนำครับ ผมกำลังหัดเขียนครับ เจอโค้ดไหนง่ายๆเลยเอามาใช้ก่อนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-05-18 12:05:04 By : Tcomcomsci
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากทราบว่า เราสามารถกำหนดสิทธิ์ผู้ใช้งาน โดยใช้ radio button ได้ไหมครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่