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 > ถามเรื่องการ submit ข้อมูลไปยังฟอร์มที่มีการเรียกเเสดงฟอร์มแบบ ส่งค่า id อ่ะครับ



 

ถามเรื่องการ submit ข้อมูลไปยังฟอร์มที่มีการเรียกเเสดงฟอร์มแบบ ส่งค่า id อ่ะครับ

 



Topic : 125967



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



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




คือผมทำส่วนค้นหาข้อมูลครับ ถ้าใช้ฟอร์มปกติ เช่น test2.php ไรงี้จะได้ครับ เเต่พอใช้ฟอร์มในระบบที่ผมทำซึ่งต้องเรียกเปิดฟอร์มนี้จากการส่งค่าไอดี จากmain หลักมาเเสดง เช่น ฟอร์มชื่อ userdetailadmin.php ที่รับค่าไอดี = 3 จาก ฟอร์ม main1 url จะเป็น main1.php?id=3 ใช่ไหมครับ ผลการค้นหาข้อมูลมันกลับไม่เเสดงผลครับ ผมต้องเเก้ในส่วนไหนครับ

อันนี้เป็นตัวอย่างผลการค้นหาครับ (ขอเเสดงเฉพาะ url นะครับ)

ผลการค้นหาโดยฟอร์มปกติทั่วไป(test2.php)
test2

ผลการค้นหาโดยฟอร์มที่ใช้ทำระบบงาน (userdetailadmin.php) เเต่ใช้การเรียกฟอร์มเเบบ ส่งค่า id จากฟอร์มหลัก url จึงเป็น (main1.php?id=3)
useradmin

อันนี้เป็นcode ฟอร์มที่เกี่ยวข้องนะครับ

main1.php อันนี้เป็นฟอร์มหลังจาก ลงชื่อเข้าใช้นะครับ จะทำการเปิดฟอร์มอื่นๆต่อไปโดยการส่งค่าเป็น id ครับ
Code (PHP)
<?php
session_start(); //เปิด session
$ses_userid =$_SESSION[ses_userid];                                          //สร้าง session สำหรับเก็บค่า ID
$ses_username = $_SESSION[ses_username];
$ses_name = $_SESSION[ses_name];
unset ( $_SESSION['ses_toppic'] );
unset ( $_SESSION['ses_detail'] );                      //สร้าง session สำหรับเก็บค่า username
//ตรวจสอบว่าทำการ Login เข้าสู่ระบบมารึยัง
if($ses_userid <> session_id() or $ses_username ==""){
echo "Please Login to system<br />";
}
 
//ตรวจสอบสถานะว่าใช่ admin รึเปล่า ถ้าไม่ใช่ให้หยุดอยู่แค่นี้
if($_SESSION[ses_status] != "Admin") {
echo "This page for Admin only!";
echo "<a href=loginfrm.php>Back</a>";
exit();
}
?>


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>ระบบจัดการห้องพัก</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/simple-sidebar.css" rel="stylesheet">
    <link href="css/custom.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<style type="text/css">
html, body { 
   height: 100%; /* ให้ html และ body สูงเต็มจอภาพไว้ก่อน */
   margin: 0;
   padding: 0;
}
.wrapper {
   display: block;
   min-height: 100%; /* real browsers */
   height: auto !important; /* real browsers */
   height: 100%; /* IE6 bug */
   margin-bottom: -20px; /* กำหนด margin-bottom ให้ติดลบเท่ากับความสูงของ footer */
}
.footer {
   height: 20px; /* ความสูงของ footer */
   display: block;
   text-align: center;
}
body 
{
background-image : url('images/green21.jpg');
background-attachment : fixed
}
</style>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div id="wrap">
<div align="left">
</div>
  </div>

  <div id="wrapper" style="background: #FFF;box-shadow: 1px 1px 10px #999;border-radius: 7px 7px 7px 7px;">

        <!-- Sidebar -->

        <div id="sidebar-wrapper" style="background-color:yellow; ">

            <ul class="sidebar-nav">
            <div align="center">
            <img src="images/logo-crop2.png"  width="200px" height="150px">
            </div>
            <br>
            <ul style="background-color:green; "><b><font color="white">จัดการข้อมูล</font></b></ul>
                <li style="background-color:lightgreen; ">
                    <a href="?id=1"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลผู้ดูเเลระบบ </b></a>
                </li>
                  <li style="background-color:lightgreen; ">
                    <a href="?id=3"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลผู้เช่า</b></a>
                </li>
               <li style="background-color:lightgreen; ">
                    <a href="?id=2"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลการจองห้องพัก</b></a>
                </li>
              
                <li style="background-color:lightgreen; ">
                    <a href="?id=13"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลห้องพัก</b></a>
                </li>
               <li style="background-color:lightgreen; ">
                    <a href="?id=8"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลสาธารณูปโภค</b></a>
                </li>
                <ul style="background-color:green;"><font color="white"><b>เข้าพัก</b></font></ul>
                <li style="background-color:lightgreen; ">
                    <a href="?id=5"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ย้ายเข้า</b></a>
                </li>
                <li style="background-color:lightgreen; ">
                    <a href="?id=4"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> สัญญาเช่า</b></a>
                </li>
                <li style="background-color:lightgreen; ">
                    <a href="?id=6"><b> <spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ย้ายห้อง</b></a>
                </li>
                <li style="background-color:lightgreen; ">
                    <a href="?id=7"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> เลิกเช่า/คืนห้อง</b></a>
                </li>
                 <ul style="background-color:green; "><font color="white"><b>คิดค่าเช่า/ชำระเงิน</b></font></ul>
                <li style="background-color:lightgreen; ">
                    <a href="?id=9"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> คิดค่าเช่า</b></a>
                </li>
                <li style="background-color:lightgreen; ">
                    <a href="?id=10"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ชำระเงินค่าเช่า</b></a>
                </li>
                <li style="background-color:lightgreen; ">
                    <a href="?id=11"><b><spen class="glyphicon glyphicon-hand-right" aria-hidden="true"></spen> ข้อมูลรายรับ</b></a>
                </li>
            </ul>
        </div>
        <!-- /#sidebar-wrapper -->

        <!-- ปุ่มเปิดปิด sidebar -->
        <div id="page-content-wrapper">
        <div align="right">
<p style="background-color:lightblue;font-size:16px; ">
  <b>สวัสดี Admin : &nbsp;<?echo "$ses_username";?>&nbsp;&nbsp;<a href="logout.php"><spen class="glyphicon glyphicon-off" aria-hidden="true"></spen><u>ออกจากระบบ</u></b></a>
</p>
</div>
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <a href="#menu-toggle" class="btn btn-default" id="menu-toggle"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span></a>
                    </div>
                </div>
            </div>
            <!------------- ตรงนี้ให้นำ page contene ใส่ ----------->
            <?php
				if($_GET[id]=="1")
					include "admindetail.php";
                else if($_GET[id]=="2")
                    include "reservchk.php";
				else if($_GET[id]=="3")
					include "Userdetailadmin.php";
				else if($_GET[id]=="4")
					include "prom.php";
				else if($_GET[id]=="5")
					include "movein.php";
				else if($_GET[id]=="6")
					include "roommoveadminindex.php";
				else if($_GET[id]=="7")
					include "roomcancle.php";
                    else if($_GET[id]=="8")
                    include "utility.php";
                else if($_GET[id]=="9")
                    include "calindex.php";
                else if($_GET[id]=="10")
                    include "pay.php";
                else if($_GET[id]=="11")
                    include "searchindex.php";
                     else if($_GET[id]=="12")
                    include "depostindex.php";
                     else if($_GET[id]=="13")
                    include "roomdetail.php";
                    else if($_GET[id]=="adminedit")
                    include "admindetail2.php";      
			?>
        </div>
        <!-- /#page-content-wrapper -->

    </div>
    <!-- /#wrapper --> <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Menu Toggle Script -->
    <script>
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("toggled");
    });
    </script>
    <br>

     
</div>
</div>
</div>
</body>

</html>



ฟอร์ม userdetailadmin.php อันนี้เป็นฟอร์มจัดการข้อมูลผู้เช่าครับ เป็นฟอร์มที่มีปัญหาในการเเสดงผลการค้นหาข้อมูลครับ
Code (PHP)
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>จัดการข้อมูลผู้เช่า</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<br>
<h4><b>ข้อมูลผู้เช่า</b></h4>
<br>
<br>
<button type="button" class="btn btn-success" onclick="window.open('adduseradmin.php','','width=950,height=600,left=300,top=0')"> <spen class="glyphicon glyphicon-plus" aria-hidden="true"></spen> เพิ่มข้อมูลผู้เช่า </button>
<div align="center">
<div><form method="get" action="main1.php?id=3">ค้นหา :<input type="text" name="search" id="search" placeholder="กรอกรหัสผู้ใช้งาน"><input type="text" name="search2" id="search2" placeholder="กรอกชื่อผู้ใช้งาน"> <button type="submit">ค้นหา</button></form></div>
<br>
<br>
<?
include 'connect.php';
$usersql = "SELECT * FROM tb_Customer Where Status = 'User' $where ";
      $userquery = mysql_query($usersql) or die ("Error Query [".$usersql."]");
?>

<h4><b>ตารางเเสดงข้อมูลผู้เช่า</b></h4><br>
<font color="red"><b>* ข้อมูลยังไม่ครบถ้วน</b></font><br>
<table style="width:600px;" class="table table-striped table-bordered">
  <tr>
  <td align="center"  bgcolor="lightblue" style="width:100px;""><b>รหัสผู้เช่า</b></td>
  <td align="center"  bgcolor="lightblue" style="width:200px;"><b>ชื่อผู้เช่า</b></td>
  <td align="center"  bgcolor="lightblue" ><b>จัดการข้อมูล</b></td>
</tr>
<?
while($user = mysql_fetch_array($userquery))
{
$cusid = $user["Cus_ID"];
$cusidshow =  substr("00000".$cusid,-5,5);
$idcard = $user["IDCard"];
if ($idcard == '') {
  $data = '*';
}else{
  $data = '';
}
?>

  <tr>
    <td align="center"><font color="red"><b><?php echo $data ?></b></font><? echo $cusidshow ?></td>
    <td align="center"><? echo $user["Cus_Name"];?></td>
    <td align="center">
  <button style="width:50px; " type="button" class="btn btn-info" onclick="window.open('usershow.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="ดูข้อมูล"><b><spen class="glyphicon glyphicon-search" aria-hidden="true"></spen></button></b></span>
</button>
<button style="width:50px; " type="button" class="btn btn-warning" onclick="window.open('usereditadmin.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="เเก้ไขข้อมูล"><b><spen class="glyphicon glyphicon-pencil" aria-hidden="true"></spen></button></b></span>
</button>
<button style="width:50px;" type="button" class="btn btn-danger" onclick="window.open('userdeleteadmin.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="ลบข้อมูล"><b><spen class="glyphicon glyphicon-trash" aria-hidden="true"></spen></button></b></td>
  </tr>
<?
}
?>
</table>


<?
if($_GET["search"] or $_GET["search2"] )
{
$id = $_GET["search"];
$name = $_GET["search2"];
include 'connect.php';
$usersql = "SELECT * FROM tb_Customer WHERE Cus_ID = '$id' OR Cus_Name = '$name' ";
$userquery = mysql_query($usersql) or die ("Error Query [".$usersql."]");
$user = mysql_fetch_array($userquery);
      $cusid = $user["Cus_ID"];
$cusidshow =  substr("00000".$cusid,-5,5);
$idcard = $user["IDCard"];
if ($idcard == '') {
  $data = '*';
}else{
  $data = '';
}
?>
<div align="center">
<h4><b>ตารางเเสดงข้อมูลผู้เช่า</b></h4><br>
<font color="red"><b>* ข้อมูลยังไม่ครบถ้วน</b></font><br>
<table style="width:600px;" class="table table-striped table-bordered">
  <tr>
  <td align="center"  bgcolor="lightblue" style="width:100px;""><b>รหัสผู้เช่า</b></td>
  <td align="center"  bgcolor="lightblue" style="width:200px;"><b>ชื่อผู้เช่า</b></td>
  <td align="center"  bgcolor="lightblue" ><b>จัดการข้อมูล</b></td>
</tr>
  <tr>
    <td align="center"><font color="red"><b><?php echo $data ?></b></font><? echo $cusidshow ?></td>
    <td align="center"><? echo $user["Cus_Name"];?></td>
    <td align="center">
  <button style="width:50px; " type="button" class="btn btn-info" onclick="window.open('usershow.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="ดูข้อมูล"><b><spen class="glyphicon glyphicon-search" aria-hidden="true"></spen></button></b></span>
</button>
<button style="width:50px; " type="button" class="btn btn-warning" onclick="window.open('usereditadmin.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="เเก้ไขข้อมูล"><b><spen class="glyphicon glyphicon-pencil" aria-hidden="true"></spen></button></b></span>
</button>
<button style="width:50px;" type="button" class="btn btn-danger" onclick="window.open('userdeleteadmin.php?ID=<?php echo $user["Cus_ID"];?>','','width=780,height=600,left=300,top=0')" title="ลบข้อมูล"><b><spen class="glyphicon glyphicon-trash" aria-hidden="true"></spen></button></b></td>
  </tr>
</table>
<?php
  mysql_close($objConnect);
}
?>




</div>
</div>
</div>
</div>
</div>


</body>
</html>




Tag : PHP









ประวัติการแก้ไข
2017-01-08 20:34:13
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-01-08 20:31:21 By : siwatboss View : 619 Reply : 5
 

 

No. 1

Guest


ที่ userdetailadmin.php
บรรทัด17 <div><form method="get" action="main1.php?id=3">ค้นหา :<input type="text" name="search" id="search" placeholder="กรอกรหัสผู้ใช้งาน"><input type="text" name="search2" id="search2" placeholder="กรอกชื่อผู้ใช้งาน"> <button type="submit">ค้นหา</button></form></div>

ทำไมไม่ใส่ action="userdetailadmin.php" ครับ คุณเขียนโค้ดรับค่าจาก form ที่หน้านี้ไม่ใช่เหรอ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-08 21:00:21 By : tenten
 


 

No. 2



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



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


ตอบความคิดเห็นที่ : 1 เขียนโดย : tenten เมื่อวันที่ 2017-01-08 21:00:21
รายละเอียดของการตอบ ::
มันไปหน้าฟอร์มเปล่าแบบที่ไม่ได้รับค่าจาก main1.php อ่ะครับ ไม่รุ้บอกยังไง ผมก็ไม่ค่อยชำนาญเท่าไหร่ เอาเป็นรูปละกันครับ

อันนี้ก่อนส่งข้อมูลค้นหา
ฟอมร์ปกติ

อันนี้ผลการค้นหาหลังจากทำตามวิธีคุณนะครับ (ตารางด้านล่างคือผลการค้นหานะครับ)
ฟอมร์ค้นหา



ประวัติการแก้ไข
2017-01-08 21:15:15
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-08 21:11:13 By : siwatboss
 

 

No. 3

Guest


action อันเก่าของคุณถูกแล้ว ผมเบลอเอง
ลองเปลี่ยนรับส่งค่า search เป็นแบบ post สิครับ จะได้ไหม
ผมก็มือใหม่เหมือนกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-08 22:34:39 By : tenten
 


 

No. 4



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



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


ตอบความคิดเห็นที่ : 3 เขียนโดย : tenten เมื่อวันที่ 2017-01-08 22:34:39
รายละเอียดของการตอบ ::
ประเด็นมันอยู่ที่ ฟอร์มปลายทางเเล้วอ่ะครับ ไม่รุ้จะ action ยังไง TT

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-09 09:55:41 By : siwatboss
 


 

No. 5



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



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


อ่ะเหื้อได้เเล้วคร้าบบบบบ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-09 10:03:54 By : siwatboss
 

   

ค้นหาข้อมูล


   
 

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