|
|
|
สอบถามเลื้อง checkbox array ส้างฟอมแล้วส่งค่าไปหาหน้า insert.php |
|
|
|
|
|
|
|
...
|
|
|
|
|
Date :
2019-07-03 11:05:29 |
By :
keekkeek |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<style type="text/css">
@font-face {
font-family: 'Phetsarath OT';
src: url('font/Phetsarath OT.ttf');
}
.font_article {
font-family: Phetsarath OT;
}
input[type=submit]{
font-family: Phetsarath OT;
}
</style>
<?php
$hostzz = "localhost";
$userzz = "root";
$passzz = "root";
$dbname = "test";
if(isset($_POST["txt01"])){
$txtz01=$_POST["txt01"];
}
if(isset($_POST["txt02"])){
$txtz02=$_POST["txt02"];
}
if(isset($_POST["txt03"])){
$txtz03=$_POST["txt03"];
}
if(isset($_POST["txt04"])){
$txtz04=$_POST["txt04"];
}
if(isset($_POST["txt05"])){
$txtz05=$_POST["txt05"];
}
if(isset($_POST["txt06"])){
$txtz06=$_POST["txt06"];
}
if(isset($_POST["txt07"])){
$txtz07=$_POST["txt07"];
}
if(isset($_POST["txt08"])){
$txtz08=$_POST["txt08"];
}
if(isset($_POST["txt09"])){
$txtz09=$_POST["txt09"];
}
if(isset($_POST["txt10"])){
$txtz10=$_POST["txt10"];
}
if(isset($_POST["txt11"])){
$txtz11=$_POST["txt11"];
}
if(isset($_POST["txt12"])){
$txtz12=$_POST["txt12"];
}
if(isset($_POST["txt13"])){
$txtz13=$_POST["txt13"];
}
if(isset($_POST["txt14"])){
$txtz14=$_POST["txt14"];
}
if(isset($_POST["txt15"])){
$txtz15=$_POST["txt15"];
}
if(isset($_POST["txt16"])){
$txtz16=$_POST["txt16"];
}
if(isset($_POST["txt17"])){
$txtz17=$_POST["txt17"];
}
if(isset($_POST["txt18"])){
$txtz18=$_POST["txt18"];
}
if(isset($_POST["txt19"])){
$txtz19=$_POST["txt19"];
}
if(isset($_POST["txt20"])){
$txtz20=$_POST["txt20"];
}
if(isset($_POST["txt21"])){
$txtz21=$_POST["txt21"];
}
if(isset($_POST["txt22"])){
$txtz22=$_POST["txt22"];
}
if(isset($_POST["txt23"])){
$txtz23=$_POST["txt23"];
}
if(isset($_POST["txt24"])){
$txtz24=$_POST["txt24"];
}
if(isset($_POST["txt25"])){
$txtz25=$_POST["txt25"];
}
if(isset($_POST["txt26"])){
$txtz26=$_POST["txt26"];
}
if(isset($_POST["txt27"])){
$txtz27=$_POST["txt27"];
}
if(isset($_POST["txt28"])){
$txtz28=$_POST["txt28"];
}
if(isset($_POST["txt29"])){
$txtz29=$_POST["txt29"];
}
if(isset($_POST["txt30"])){
$txtz30=$_POST["txt30"];
}
if(isset($_POST["txt31"])){
$txtz31=$_POST["txt31"];
}
if(isset($_POST["txt32"])){
$txtz32=$_POST["txt32"];
}
if(isset($_POST["txt33"])){
$txtz33=$_POST["txt33"];
}
if(isset($_POST["txt34"])){
$txtz34=$_POST["txt34"];
}
if(isset($_POST["txt35"])){
$txtz35=$_POST["txt35"];
}
if(isset($_POST["txt36"])){
$txtz36=$_POST["txt36"];
}
if(isset($_POST["txt37"])){
$txtz37=$_POST["txt37"];
}
if(isset($_POST["txt38"])){
$txtz38=$_POST["txt38"];
}
if(isset($_POST["txt39"])){
$txtz39=$_POST["txt39"];
}
if(isset($_POST["txt40"])){
$txtz40=$_POST["txt40"];
}
if(isset($_POST["txt41"])){
$txtz41=$_POST["txt41"];
}
if(isset($_POST["txt42"])){
$txtz42=$_POST["txt42"];
}
if(isset($_POST["txt43"])){
$txtz43=$_POST["txt43"];
}
if(isset($_POST["txt44"])){
$txtz44=$_POST["txt44"];
}
$array=array(
0 => $txtz01,
1 => $txtz02,
2 => $txtz03,
3 => $txtz04,
4 => $txtz05,
5 => $txtz06,
6 => $txtz07,
7 => $txtz08,
8 => $txtz09,
9 => $txtz10,
10 => $txtz11,
11 => $txtz12,
12 => $txtz13,
13 => $txtz14,
14 => $txtz15,
15 => $txtz16,
16 => $txtz17,
17 => $txtz18,
18 => $txtz19,
19 => $txtz20,
20 => $txtz21,
21 => $txtz22,
22 => $txtz23,
23 => $txtz24,
24 => $txtz25,
25 => $txtz26,
26 => $txtz27,
27 => $txtz28,
28 => $txtz29,
29 => $txtz30,
30 => $txtz31,
31 => $txtz32,
32 => $txtz33,
33 => $txtz34,
34 => $txtz35,
35 => $txtz36,
36 => $txtz37,
37 => $txtz38,
38 => $txtz39,
39 => $txtz40,
40 => $txtz41,
41 => $txtz42,
42 => $txtz43,
43 => $txtz44,
);
$c =0;
foreach($array as $key => $value){
if($value == 1){
$c= $c+1;
}
}
if($c <17 || $c>17){
header("location:wrong.php");
}else{
$conn = mysqli_connect($hostzz,$userzz,$passzz,$dbname);
$sql = "INSERT INTO `member_1` (`kesone`, `yod`, `vanna`, `sivilay`, `silavanh`, `phavanna`, `chanaob`, `davone`, `phisitphai`, `chaimali`, `viengthong`, `bounsong`, `niyom`, `khambang`, `anouthida`, `sengsuda`, `khommaly`, `phavanh`, `anisone`, `maniphone`, `naphalai`, `maithao`, `manomai`, `sibounheng`, `thipphavanh`, `davone_sommani`, `viengsai`, `vannasone`, `vipaiphone_t`, `toulavanh`, `chinda`, `sivai`, `phengthala`, `saijai`, `kittisuk`, `thunyalut`, `soutsada`, `luttaphone`, `khamtai`, `panou`, `keopaserth`, `vilaiphone`, `phonesavanh`, `malilamone`) VALUES ('$txtz01', '$txtz02', '$txtz03', '$txtz04', '$txtz05', '$txtz06', '$txtz07', '$txtz08', '$txtz09', '$txtz10', '$txtz11', '$txtz12', '$txtz13', '$txtz14', '$txtz15', '$txtz16', '$txtz17', '$txtz18', '$txtz19', '$txtz20', '$txtz21', '$txtz22', '$txtz23', '$txtz24', '$txtz25', '$txtz26', '$txtz27', '$txtz28', '$txtz29', '$txtz30', '$txtz31', '$txtz32', '$txtz33', '$txtz34', '$txtz35', '$txtz36', '$txtz37', '$txtz38', '$txtz39', '$txtz40', '$txtz41', '$txtz42', '$txtz43', '$txtz44')";
$query = mysqli_query($conn,$sql);
{
header("location:index.php");
}
mysqli_close($conn);
}
?>
</head>
</html>
|
|
|
|
|
Date :
2019-07-03 11:05:51 |
By :
keekkeek |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะไม่ใช่คนไทย 5555
เอาโค๊ดมาลงไว้ด้วยครับ จะได้แนะนำได้ถูก
---- อ้าวลง อีก คห. ไม่ทันเห็น 555
|
ประวัติการแก้ไข 2019-07-03 11:07:15
|
|
|
|
Date :
2019-07-03 11:06:09 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เยอะขนาดนี้ใช้ input array เถอะ อย่าเหนื่อยเลย
|
|
|
|
|
Date :
2019-07-03 11:22:44 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ได้แล้ว ขอบใจหลายๆ
if(isset($_POST["txt01"])){
$txtz01=$_POST["txt01"];
}else{
$txtz01= 0;
}
|
|
|
|
|
Date :
2019-07-03 11:40:53 |
By :
keekkeek |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
if(isset($_POST["txt01"])){
$txtz01=$_POST["txt01"];
}else{
$txtz01= 0;
}
...
if(isset($_POST["txt43"])){
$txtz43=$_POST["txt43"];
}else{
$txtz43= 0;
}
$array=array(
0=>$txtz01,
...
43=>$txtz43
);
ยาวไป เขียนแบบ สั้นๆ
Code (PHP)
$array=[];
for($i=0; $i<43;$i++){
$array[] = isset($_POST['txt'.substr(100+i,1)])?1 : 0;
}
ตัว form ก็เหมือนกัน เขียนให้สั้นได้ ใช้ loop ช่วย
|
|
|
|
|
Date :
2019-07-03 13:14:40 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2019-07-03 17:09:02 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|