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 > ช่วยแก้โค้ด เก็บค่าcheck box ลงใน ฟิลเดียวกันที่ครับ Please.......



 

ช่วยแก้โค้ด เก็บค่าcheck box ลงใน ฟิลเดียวกันที่ครับ Please.......

 



Topic : 130415



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



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




บันทึกข้อมูลจาก text box "ได้ แต่ ไม่บันทึกข้อมูลที่เป็น check box




form =============

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>สมัครสมาชิกช่างภาพ</title>
<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 377px;
	top: 144px;
	width: 639px;
	height: 1411px;
	z-index: 1;
	color: #FFF;
}
body {
	background-color: #666;
}
</style>
</head>

<body>
<div id="apDiv1">
  <form id="form2" name="form2" method="post" action="registerchang2.php">
    <h4 align="center">&nbsp;</h4>
    <div align="center">
      <h4 align="center">** ชื่อสตูดิโอ แสดงด้านบนสุดของโปรไฟล์(ไม่เกิน 24 ตัวอักษร)</h4>
      <p align="center">
        <label for="tx_studio"></label>
        <input name="tx_studio" type="text" id="tx_studio" size="50" maxlength="25" />
      </p>
      <h4 align="center">** ข้อความเชิญชวน (ไม่เกิน 60 ตัวอักษร)</h4>
      <p align="center">
        <label for="tx_ss"></label>
        <input name="tx_ss" type="text" id="tx_ss" size="70" maxlength="60" />
      </p>
      <p>&nbsp;</p>
      <table width="431" height="314" border="1">
        <tr>
          <td width="113">Username</td>
          <td width="144"><label for="tx_user"></label>
          <input type="text" name="tx_user" id="tx_user" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><label for="tx_pass"></label>
          <input type="password" name="tx_pass" id="tx_pass" /></td>
        </tr>
        <tr>
          <td>Confirm Password</td>
          <td><label for="tx_cpass"></label>
          <input type="password" name="tx_cpass" id="tx_cpass" /></td>
        </tr>
        <tr>
          <td>Name</td>
          <td><label for="tx_name"></label>
          <input type="text" name="tx_name" id="tx_name" /></td>
        </tr>
        <tr>
          <td>E-mail</td>
          <td><label for="tx_email"></label>
          <input type="text" name="tx_email" id="tx_email" /></td>
        </tr>
        <tr>
          <td>Tel.</td>
          <td><label for="tx_tel"></label>
          <input type="text" name="tx_tel" id="tx_tel" /></td>
        </tr>
        <tr>
          <td>สถานที่รับงาน</td>
          <td><label>
            <input name="cblocation" type="checkbox" id="สถานที่รับงาน_0" value="กรุงเทพ" />
            กรุงเทพฯ</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ภาคกลาง" id="สถานที่รับงาน_1" />
              ภาคกลาง</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ภาคเหนือ" id="สถานที่รับงาน_2" />
              ภาคเหนือ</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ตะวันออก" id="สถานที่รับงาน_3" />
              ตะวันออก</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ตะวันออกเฉียงเหนือ" id="สถานที่รับงาน_4" />
              ตะวันออกเฉียงเหนือ</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ตะวันตก" id="สถานที่รับงาน_5" />
              ตะวันตก</label>
            <br />
            <label>
              <input type="checkbox" name="cblocation" value="ภาคใต้" id="สถานที่รับงาน_6" />
          ภาคใต้</label></td>
        </tr>
      </table>
    </div>
    <h4 align="center">ประเภทงานที่รับ และราคา<br />
      **คลิกเลือกเครื่องหมาย  งานที่รับ และใส่ราคางาน</h4>
    <div align="center">
      <table width="624" height="587" border="1">
        <tr>
          <td width="46" height="40"><label for="W1">
            <input type="checkbox" name="cbwork" value="รับปริญญา" id="สถานที่รับงาน_7" />
          </label></td>
          <td width="77">&nbsp;</td>
          <td width="138">รับปริญญา</td>
          <td width="335"><p>ราคาเต็มวัน
            <label for="baht1"></label>
            <input type="text" name="baht1" id="baht1" />
            </p>
            <p>ราคาครึ่งวัน
              <label for="baht3"></label>
              <input type="text" name="baht2" id="baht2" />
          </p></td>
        </tr>
        <tr>
          <td height="88"><input type="checkbox" name="cbwork" value="ภาพบุคคล" id="สถานที่รับงาน_8" /></td>
          <td>&nbsp;</td>
          <td>ภาพบุคคล / แฟชั่น</td>
          <td><p>ราคาเต็มวัน
            <input type="text" name="baht3" id="baht3" />
            </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht4" id="baht4" />
          </p></td>
        </tr>
        <tr>
          <td height="90"><input type="checkbox" name="cbwork" value="งานแต่ง" id="สถานที่รับงาน_9" /></td>
          <td>&nbsp;</td>
          <td>งานแต่ง</td>
          <td><p>ราคาเต็มวัน
            <input type="text" name="baht5" id="baht5" />
            </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht6" id="baht6" />
          </p></td>
        </tr>
        <tr>
          <td height="81"><input type="checkbox" name="cbwork" value="พีเวดดิง" id="สถานที่รับงาน_10" /></td>
          <td>&nbsp;</td>
          <td>พรีเวดดิง</td>
          <td><p>ราคาเต็มวัน
              <strong>
              <input type="text" name="baht7" id="baht7" />
              </strong>            </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht8" id="baht8" />
          </p></td>
        </tr>
        <tr>
          <td height="84"><input type="checkbox" name="cbwork" value="งานอีเวนต์" id="สถานที่รับงาน_11" /></td>
          <td>&nbsp;</td>
          <td>งานอีเวนต์</td>
          <td><p>ราคาเต็มวัน
            <input type="text" name="baht9" id="baht9" />
            </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht10" id="baht10" />
          </p></td>
        </tr>
        <tr>
          <td height="77"><input type="checkbox" name="สถานที่รับงาน_" value="สถาปัตยกรรม" id="สถานที่รับงาน_12" /></td>
          <td>&nbsp;</td>
          <td>สถาปัตยกรรม</td>
          <td><p>ราคาเต็มวัน
            <input type="text" name="baht11" id="baht11" />
            </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht12" id="baht12" />
          </p></td>
        </tr>
        <tr>
          <td height="82">&nbsp;</td>
          <td>&nbsp;</td>
          <td><p>อื่นๆ
 (โปรดระบุ)</p>
            <p>
  <input name="textfield" type="text" id="textfield" size="15" maxlength="15" />
          </p></td>
          <td><p>ราคาเต็มวัน
            <input type="text" name="baht13" id="baht13" />
          </p>
            <p>ราคาครึ่งวัน
              <input type="text" name="baht14" id="textfield3" />
          </p></td>
        </tr>
      </table>
    </div>
    <p align="center">
      <input type="submit" name="button" id="button" value="ยืนยัน" />
    </p>
    <p align="center">&nbsp;</p>
  </form>
</div>
<form id="form1" name="form1" method="post" action="">
  <p align="center"><img src="../photo/regisbg.jpg" width="1106" height="1534" /></p>
</form>
</body>
</html>










code : ===================



Code (PHP)
<?php
	mysql_connect("localhost","root","123456789");
	mysql_select_db("neramit");
	
	if(trim($_POST["tx_studio"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input Studio Name");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
			 		exit();
	}
		if(trim($_POST["tx_ss"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input detail");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}
	
		if(trim($_POST["tx_user"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input Username");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}
	
	if(trim($_POST["tx_pass"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input your password");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}	
		
	if($_POST["tx_pass"] != $_POST["tx_cpass"])
	{
			 ?>
                	<script language="javascript" >
						alert("Password not Match");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();
	}
	
	if(trim($_POST["tx_name"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input your Name");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}	
	
		if(trim($_POST["tx_email"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input Your E-mail");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}	
	
		if(trim($_POST["tx_tel"]) == "")
	{
			 ?>
                	<script language="javascript" >
						alert("please input your telephonenumber");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
		exit();	
	}	
	
	$strSQL = "SELECT * FROM photographer WHERE ch_username = '".trim($_POST['tx_user'])."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	if($objResult)
	{
			 ?>
                	<script language="javascript" >
						alert("Username already exists");
						window.location.replace("registerchang1.php")
					</script>>
      	 	 <?
	}
	else
	{	
				}
	for($i=0;$i<count($_POST["cblocation"]);$i++)
	{
		if($_POST["cblocation"][$i] != "")
		{
			
		$strSQL = "INSERT INTO photographer (ch_studio,ch_comeon,ch_username,ch_password,ch_name,ch_email,ch_telephone,ch_location) VALUES ('".$_POST["tx_studio"]."','".$_POST["tx_ss"]."','".$_POST["tx_user"]."','".$_POST["tx_pass"]."','".$_POST["tx_name"]."','".$_POST["tx_email"]."','".$_POST["tx_tel"]."','".$_POST["cblocation"][$i]."')";
		$objQuery = mysql_query($strSQL);
}
	}
			?>
                	<script language="javascript" >
						alert("Register Completed!");
						window.location.replace("login.php")
					</script>>
      	 	<?
		
	



	mysql_close();
?>
<!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>สมัครสมาชิกสำเร็จ</title>
</head>

<body>
</body>
</html>





Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2018-02-26 18:14:10 By : 0808320818 View : 745 Reply : 8
 

 

No. 1



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



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


database






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-26 18:16:09 By : 0808320818
 


 

No. 2



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

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

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

ต้องกำหนด input checkbox ให้เป็น array ด้วยครับ ถึงจะรับค่าแบบ array ได้

Code (PHP)
<input type="checkbox" name="cblocation[]" value="ภาคกลาง" id="สถานที่รับงาน_1" />
<input type="checkbox" name="cblocation[]" value="ภาคเหนือ" id="สถานที่รับงาน_2" />
<input type="checkbox" name="cblocation[]" value="ตะวันออก" id="สถานที่รับงาน_3" />

etc...

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 02:50:02 By : Manussawin
 

 

No. 3



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



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


บางอย่างใช้ radio ดีกว่า checkbox เลือกใช้ให้ถูกต้อง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 08:42:18 By : Chaidhanan
 


 

No. 4



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



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


ตอบความคิดเห็นที่ : 2 เขียนโดย : Manussawin เมื่อวันที่ 2018-02-27 02:50:02
รายละเอียดของการตอบ ::
... ใส่ความคิดเห็นตรงนี้.......


ผมลองแล้ว ทำไมมันบันทึกข้อมูลซ้ำกันแบบนี้อะ

1


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 09:59:10 By : 0808320818
 


 

No. 5



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



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


ต้องการใส่เข้าไปใน field แบบไหนครับ เอาตัวอย่างมาดู ตามโค๊ดมัน insert ทุกๆ element ใน array
โดยมี ข้อมูลเปลี่ยนแปลง แค่รายการเดียว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 10:05:49 By : Chaidhanan
 


 

No. 6



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



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


ตอบความคิดเห็นที่ : 5 เขียนโดย : Chaidhanan เมื่อวันที่ 2018-02-27 10:05:49
รายละเอียดของการตอบ ::
ผมอยากได้ 1ชื่อ เก็บ สถานที่ได้มากกว่า1ครับ
ประณานนี้
ชื้อ......................ข้อมูล................... email...................โทรศัพ.......................สถานที่.....
aaa aaaa.............1234.................. [email protected] ....0899999999.......... กรุงเทพ,ภาคเหนือ,ภาคกลาง,อื่นๆ




ประวัติการแก้ไข
2018-02-27 10:24:38
2018-02-27 10:24:43
2018-02-27 10:24:51
2018-02-27 10:24:56
2018-02-27 10:25:00
2018-02-27 10:25:05
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 10:23:06 By : 0808320818
 


 

No. 7



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



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


$strSQL = "INSERT INTO photographer (ch_studio,ch_comeon,ch_username,ch_password,ch_name,ch_email,ch_telephone,ch_location) VALUES ('".$_POST["tx_studio"]."','".$_POST["tx_ss"]."','".$_POST["tx_user"]."','".$_POST["tx_pass"]."','".$_POST["tx_name"]."','".$_POST["tx_email"]."','".$_POST["tx_tel"]."','".implode(',', $_POST["cblocation"])."')";

เอา loop ออกด้วยนะครับ จะได้เหลือรายการเดียว


ประวัติการแก้ไข
2018-02-27 10:52:58
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 10:52:15 By : Chaidhanan
 


 

No. 8



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



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


ตอบความคิดเห็นที่ : 7 เขียนโดย : Chaidhanan เมื่อวันที่ 2018-02-27 10:52:15
รายละเอียดของการตอบ ::
ขอบคุณมากครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-02-27 13:00:59 By : 0808320818
 

   

ค้นหาข้อมูล


   
 

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