  | 
              
	              
	                
  
    
	 
        ช่วยแก้โค้ด เก็บค่าcheck box ลงใน ฟิลเดียวกันที่ครับ Please.......     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                บันทึกข้อมูลจาก 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"> </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> </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"> </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> </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> </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> </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> </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> </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"> </td>
          <td> </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"> </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               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-02-26 18:14:10 | 
                      By :
                          0808320818 | 
                      View :
                          889 | 
                      Reply :
                          8 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                                          
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-02-26 18:16:09 | 
                        By :
                            0808320818 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ต้องกำหนด 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 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 บางอย่างใช้ radio ดีกว่า checkbox เลือกใช้ให้ถูกต้อง                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-02-27 08:42:18 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ต้องการใส่เข้าไปใน field แบบไหนครับ เอาตัวอย่างมาดู ตามโค๊ดมัน insert ทุกๆ element ใน array 
โดยมี ข้อมูลเปลี่ยนแปลง แค่รายการเดียว                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-02-27 10:05:49 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 $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 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |