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 > ช่วยดูการประกาศ Session หน่อยค่ะ คือทำการเพิ่มข้อมูลแล้วมันไม่ขึ้นข้อมูลชื่อ ค่ะ



 

ช่วยดูการประกาศ Session หน่อยค่ะ คือทำการเพิ่มข้อมูลแล้วมันไม่ขึ้นข้อมูลชื่อ ค่ะ

 



Topic : 057250



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



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




ส่วนของการเพิ่มข้อมูลค่ะ

Code (PHP)
<?php
	session_start(); 
	include("connect.php");?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ระบบงานซ่อมบำรุง ฝ่ายอาคารสถานที่ มหาวิทยาลัยเกษตรศาสตร์ วิทยาเขตเฉลิมพระเกียรติ จังหวัดสกลนคร</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	background-color: #D5FFD5;
}
a {
	font-family: Tahoma;
}
a:link {
	color: #000000;
}
a:visited {
	color: #000000;
}
a:hover {
	color: #FF0000;
}
a:active {
	color: #CC3333;
}
.style28 {color: #999999}
.style29 {color: #FF0000}
-->
</style>
</head>
<?php 
$sql = "select * from applicant";
$result = mysql_query($sql);
?>
<body>
<script language="javascript">
function IsNumeric(sText,obj)
{
var ValidChars = "0123456789-";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++) {
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1) {
IsNumber = false;
}
}
if(IsNumber==false){
alert("กรอกได้เฉพาะตัวเลขเท่านั้น");
obj.value=sText.substr(0,sText.length-1);
}
}
</script>

<script type="text/javascript">
function chkValidate(){
	var App_ID=document.getElementById("App_ID");
	if(App_ID.value==null||App_ID.value==""){
		alert("กรุณาป้อน รหัสพนักงานผู้ขอใช้บริการด้วยค่ะ");
	return false;
	}
	var App_Title=document.getElementById("App_Title");
	if(App_Title.value==คำนำหน้า||App_Title.value==""){
		alert("กรุณาป้อนคำนำหน้าชื่อด้วยค่ะ");
	return false;
	}
	var App_Fname=document.getElementById("App_Fname");
	if(App_Fname.value==null||App_Fname.value==""){
		alert("กรุณาป้อน ชื่อด้วยค่ะ");
	return false;
	
  }
		
	var App_Lname=document.getElementById("App_Lname");          
   	if(App_Lname.value==null||App_Lname.value==""){
		alert("กรุณาป้อน นามสกุล ด้วยค่ะ");
	return false;
	 }
		
	var Tel=document.getElementById("Tel");
	if(Tel.value==null||Tel.value==""){
		alert("กรุณาป้อน เบอร์โทรศัพท์ด้วยค่ะ");
	return false;
	}
	var InternalTel=document.getElementById("InternalTel");
	if(InternalTel.value==null||InternalTel.value==""){
		alert("กรุณาป้อน เบอร์โทรศัพท์ภายใน ด้วยค่ะ"); 
		
	return false;
	}
	var Agencies_ID=document.getElementById("Agencies_ID");
	if(Agencies_ID.value==null||Agencies_ID.value==""){
		alert("กรุณาป้อน หน่วยงาน ด้วยค่ะ");
		
	return false;
	}
	var Position=document.getElementById("Position");
	if(Position.value==null|| Position.value==""){
		alert("กรุณาป้อน ตำแหน่ง  ด้วยค่ะ");
	
	return false;
	}
	
	return true;
	
}
</script>

<table width="915" height="150
" border="0" align="center" background="images/head.jpg">
  <tr>
    <th width="450" height="150" scope="col">&nbsp;</th>
  </tr>
</table> <br>
<form action="check_applicant1.php"  name="addform" method="post" onSubmit="return chkValidate(this);">
<table width="915" height="300" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
  <tr>
    <th height="37" colspan="2" align="left" valign="top" bordercolor="#97FF97" bgcolor="#97FF97" scope="col"><table width="898" height="43" border="0" align="center" bordercolor="#D5FFD5">
      <tr>
        <th width="892" height="39" align="center" bordercolor="#97FF97" bgcolor="#97FF97" scope="col">
		  </th>
      </tr>
    </table>
	  <p></p>
	<p></p>
	<p> </p>
	
	
           <div align="right"></div>
<div align="right"></div></th>
    </tr>
  <tr>
    <th width="114" height="300" align="left" valign="top" bgcolor="#FFFFFF" >&nbsp; &nbsp; &nbsp;
      <p>&nbsp;</p>
	  
	  <p>&nbsp;</p>	  <p></p></th>
    <th width="791" height="38" align="left" valign="top" bgcolor="#FFFFFF" scope="col"><div align="right"> 
     <p><div align="right"class="font">วันที่ 
	<span class="font3"><?php   
$_month_name = array("01"=>"มกราคม",  "02"=>"กุมภาพันธ์",  "03"=>"มีนาคม",         
"04"=>"เมษายน",  "05"=>"พฤษภาคม",  "06"=>"มิถุนายน",       
"07"=>"กรกฎาคม",  "08"=>"สิงหาคม",  "09"=>"กันยายน",        
"10"=>"ตุลาคม", "11"=>"พฤศจิกายน",  "12"=>"ธันวาคม");  
$vardate=date('Y-m-d'); 
$yy=date('Y'); 
$mm =date('m');$dd=date('d');  
if ($dd<10){  
$dd=substr($dd,1,2); 
} 
$date=$dd ." ".$_month_name[$mm]."  ".$yy+= 543; 
echo $date; 
?></span>&nbsp;</div></p>
 
    </div>
	<p>&nbsp;</p>
	<div>
	  <table width="356" height="37" border="0">
        <tr>
          <th width="350" scope="col"><div align="left" class="font4">กรุณากรอกข้อมูลส่วนตัวก่อนขอใช้บริการ</div></th>
        </tr>
      </table>
	  <table width="675" height="282" border="0" >
  <tr>
    <th width="669" height="278" valign="top" scope="col">
	<table width="413" height="240" border="0" align="center" >
      <tr>
        <td width="118" height="31" scope="col"><div align="right" class="font">รหัสผู้ขอใช้บริการ :</div></td>
        <td width="285" scope="col"><div align="left">
          <input name="App_ID" type="text"  id="App_ID" size="20" class="font" title="กรุณากรอกรหัสผู้ขอใช้บริการ">
          &nbsp;<span class="style29">*</span></div></td>
      </tr>
      <tr>
        <td height="26"><div align="right" class="font">คำนำหน้าชื่อ :</div></td>
        <td><div align="left">
          <select name ="App_Title" size="1" id="App_Title" class="font" title="กรุณากรอกคำนำหน้าชื่อ">
            <option value="--"> คำนำหน้า</option>
            <option value="นาย"> นาย</option>
            <option value="นาง"> นาง</option>
            <option value="นางสาว"> นางสาว</option>
          </select>          
          &nbsp;<span class="style29">*</span></div></td>
      </tr>
      <tr>
        <td height="28"><div align="right" class="font">ชื่อ :</div></td>
        <td>
                <div align="left">
                  <input name="App_Fname" type="text" id="App_Fname" size="20" class="font" title="กรุณากรอกชื่อ" />
                  &nbsp;<span class="style29">*</span></div></td>
      </tr>
      <tr>
        <td height="28"><div align="right" class="font">สกุล :</div></td>
        <td><div align="left">
          <input name="App_Lname" type="text" id="App_Lname" size="20" class="font" title="กรุณากรอกนามสกุล"/>
          &nbsp;<span class="style29">*</span></div></td>
      </tr>
      <tr>
        <td height="27"><div align="right" class="font">เบอร์โทรส่วนตัว :</div></td>
        <td><div align="left">
          <input name="Tel" type="text" id="Tel" size="20" class="font" title="กรุณากรอกเบอร์โทรส่วนตัว" onKeyUp="IsNumeric(this.value,this)"/>
          &nbsp;</div></td>
      </tr>
      <tr>
        <td height="30" class="font"><div align="right">เบอร์โทรภายใน :</div></td>
        <td><div align="left">
          <input name="InternalTel" type="text" id="InternalTel" size="20" class="font" title="กรุณากรอกเบอร์ภายใน" 
			  onKeyUp="IsNumeric(this.value,this)" />
          &nbsp;</div></td>
      </tr>
      <tr>
        <td height="24"><div align="right" class="font">ตำแหน่ง :</div></td>
        <td><div align="left">
          <input name="Position" type="text" id="Position" size="20" class="font" title="กรุณากรอกตำแหน่ง"/>
          &nbsp;<span class="style29">*</span></div></td>
      </tr>
      <tr>
        <td height="28" class="font"><div align="right">หน่วนงาน :</div></td>
        <td><div align="left">
          <select name="Agencies_ID" class="font" id="Agencies_ID">
            <option>--กรุณาเลือกหน่วยงาน--</option>
            <? $sql = "select * from agencies";
			  	 $result = mysql_query($sql);
				 while($row = mysql_fetch_array($result)){
			  ?>
            <option value="<?=$row['Agencies_ID']?>"><? echo $row['AgenciesName'];?></option>
            <? }?>
          </select>          
          <span class="style29">*</span>&nbsp;</div></td>
      </tr>
    </table>
	  <table width="410" height="31" border="0" align="center">
        <tr>
            <th width="455" height="30" scope="col"><input name="submit" type="submit" value="บันทึก"/>&nbsp;
				<input type="reset" name="Submit4" value="ยกเลิก"  onclick="document.location='add_applicant.php'; " /></th>
        </tr>
      </table>	  <p>&nbsp;</p>
	
	</th>
  </tr>
</table>
<table width="200" border="0" align="right">
  <tr>
    <th height="29" scope="col"><a href="logout.php" class="style14">ออกจากระบบ</a>&nbsp;</th>
  </tr>
</table>

</div>
  </th>
  </tr> 
</table>
</form>
</body>
</html>


ส่วนของการcheckการเพิ่มข้อมูลค่ะ

Code (PHP)
<? session_start();
 include("connect.php");?>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
    $App_ID = $_GET["id"];
	$App_ID = $_POST["App_ID"];
	$App_Title = $_POST["App_Title"];
	$App_Fname = $_POST["App_Fname"];
	$App_Lname = $_POST["App_Lname"];
	$Tel=$_POST["Tel"];
	$InternalTel = $_POST["InternalTel"];
	$Position = $_POST["Position"];
	$Agencies_ID = $_POST["Agencies_ID"];
	
$check=mysql_query("select App_ID from applicant where App_ID= '" . $App_ID . "'");
if(mysql_num_rows($check) > 0){
echo "<script>alert('รหัสผู้ขอใช้บริการซ้ำ กรุณากรอกรหัสผู้ขอใช้บริการใหม่ค่ะ');</script>";
echo "<meta http-equiv='refresh'content='2;url=add_applicant.php'>";
exit();

}
	else
	{
		$row=mysql_query("insert into applicant values
	('$App_ID','$App_Title','$App_Fname','$App_Lname','$Tel','$InternalTel','$Position','$Agencies_ID')");

	if($row){
				$App_Fname = $row['App_Fname'];
				$id = $row['App_ID'];
				$App_ID= $row['App_ID'];
				$_SESSION["id"] = $App_ID;
				$_SESSION["appid"] = $id;
				$_SESSION["App_Fname"]=$row['App_Fname'];
       			$_SESSION["App_ID"] = $row['App_ID'];
      			session_write_close();
						echo "<script>alert('ยินดีต้อนรับคุณ $App_Fname เข้าสู่ระบบ');</script>";
				 	 	echo "<meta http-equiv='refresh'content='2;url=main.php'>";
			   }
			    else{
				echo "<script>alert('ไม่สามารถเพิ่มข้อมูลผู้ขอใช้บริการได้');</script>";
		       echo "<meta http-equiv='refresh'content='2;url=add_applicant.php'>";
			   }
		}	  
	?>	   
		      
	<?		
 mysql_close($connect);
?>



พอเพิ่มข้อมูลแล้วมันไม่แสดง App_Fname ค่ะ ช่วยหน่อยนะค่ะหมดปัญญาแล้วค่ะ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-03-14 21:34:26 By : l3uil3ui View : 789 Reply : 4
 

 

No. 1



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



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


T_T






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-14 23:15:24 By : l3uil3ui
 


 

No. 2



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

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

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


$row=mysql_query("insert into applicant values
('$App_ID','$App_Title','$App_Fname','$App_Lname','$Tel','$InternalTel','$Position','$Agencies_ID')");


นี่มัน insert ไม่ใช่ select มันจะมีอะไรออกมาได้ไง

Code (PHP)
				$App_Fname = $row['App_Fname'];
				$id = $row['App_ID'];
				$App_ID= $row['App_ID'];
				$_SESSION["id"] = $App_ID;
				$_SESSION["appid"] = $id;
				$_SESSION["App_Fname"]=$row['App_Fname'];
       			$_SESSION["App_ID"] = $row['App_ID'];



ดูแล้วยังเขียนแปลกๆ นะ
$_SESSION["id"] = $App_ID;
$_SESSION["appid"] = $id;


ไอ้นี่ผิดแน่นอน
Code (PHP)
				$App_Fname = $row['App_Fname'];
				$id = $row['App_ID'];
				$App_ID= $row['App_ID'];


$App_Fname ถูกส่งมาาแล้วเอาไปใช้ได้เล่ย

ไอ้นี่ยังงงๆ
$_SESSION["id"] = $App_ID;
$_SESSION["appid"] = $id;


สรุปแล้ว คุณลองพิจารณาดีๆ ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-14 23:23:28 By : PlaKriM
 

 

No. 3



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



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


แล้วต้องเปลี่ยน $row=mysql_query("insert into applicant values
('$App_ID','$App_Title','$App_Fname','$App_Lname','$Tel','$InternalTel','$Position','$Agencies_ID')");
เป็น select หมดเลยหรอค่ะ
หรือต้องเพิ่มในส่วนไหนค่ะ

รบกวนอีกทีค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-15 00:46:49 By : l3uil3ui
 


 

No. 4



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



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


ขอบคุณมากๆค่ะได้แล้วค่ะ Code (PHP)
<? session_start();
 include("connect.php");?>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
    $App_ID = $_GET["id"];
	$App_ID = $_POST["App_ID"];
	$App_Title = $_POST["App_Title"];
	$App_Fname = $_POST["App_Fname"];
	$App_Lname = $_POST["App_Lname"];
	$Tel=$_POST["Tel"];
	$InternalTel = $_POST["InternalTel"];
	$Position = $_POST["Position"];
	$Agencies_ID = $_POST["Agencies_ID"];
	
$check=mysql_query("select App_ID from applicant where App_ID= '" . $App_ID . "' ");
if(mysql_num_rows($check) > 0){
echo "<script>alert('รหัสผู้ขอใช้บริการซ้ำ กรุณากรอกรหัสผู้ขอใช้บริการใหม่ค่ะ');</script>";
echo "<meta http-equiv='refresh'content='2;url=add_applicant.php'>";
exit();

}
	else
	{
		$bui=mysql_query("insert into applicant values
	('$App_ID','$App_Title','$App_Fname','$App_Lname','$Tel','$InternalTel','$Position','$Agencies_ID')");
	if($bui){
		$sql = " SELECT * FROM applicant WHERE App_Fname = '".trim($_POST['App_Fname'])."' ";
   		$result = mysql_query($sql);
		$row = mysql_fetch_array($result); 
		 	if($row)
			{
				$App_Fname = $row['App_Fname'];
				$id = $row['App_ID'];
				$App_ID= $row['App_ID'];
				$_SESSION["id"] = $App_ID;
				$_SESSION["appid"] = $id;
				$_SESSION["App_Fname"]=$row['App_Fname'];
       			$_SESSION["App_ID"] = $row['App_ID'];
      			session_write_close();
						echo "<script>alert('ยินดีต้อนรับคุณ $App_Fname เข้าสู่ระบบ');</script>";
				 	 	echo "<meta http-equiv='refresh'content='2;url=main.php'>";
			   }
			    else{
				echo "<script>alert('ไม่สามารถเพิ่มข้อมูลผู้ขอใช้บริการได้');</script>";
		       echo "<meta http-equiv='refresh'content='2;url=add_applicant.php'>";
			   }
		}
	}	  
	?>	   
		      
	<?		
 mysql_close($connect);
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-15 00:51:34 By : l3uil3ui
 

   

ค้นหาข้อมูล


   
 

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