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 : 132099



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



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




Code (PHP)
<?php require_once('Connections/conweb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_conweb, $conweb);
$query_run = "SELECT * FROM run_bangbo";
$run = mysql_query($query_run, $conweb) or die(mysql_error());
$row_run = mysql_fetch_assoc($run);
$totalRows_run = mysql_num_rows($run);

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))


 {
  $insertSQL = sprintf("INSERT INTO run_bangbo (name_th, name_en, cid, natity, gen, bri_day, age, blood_type, phone, con_dise, name_con, tel_con, categry, t_shirt) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['name_th'], "text"),
                       GetSQLValueString($_POST['name_en'], "text"),
                       GetSQLValueString($_POST['cid'], "int"),
                       GetSQLValueString($_POST['natity'], "text"),
                       GetSQLValueString($_POST['gen'], "text"),
                       GetSQLValueString($_POST['bri_day'], "text"),
                       GetSQLValueString($_POST['age'], "int"),
                       GetSQLValueString($_POST['blood_type'], "text"),
                       GetSQLValueString($_POST['phone'], "int"),
                       GetSQLValueString($_POST['con_dise'], "text"),
                       GetSQLValueString($_POST['name_con'], "text"),
                       GetSQLValueString($_POST['tel_con'], "int"),
                       GetSQLValueString($_POST['categry'], "int"),
                       GetSQLValueString($_POST['t_shirt'], "text"));

  mysql_select_db($database_conweb, $conweb);
  $Result1 = mysql_query($insertSQL, $conweb) or die(mysql_error());

  $insertGoTo = "pre_run.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

<!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>
<title></title>
  </script>
   

	<!-- The following line loads the template CSS file located in the template folder. -->


	<link rel="stylesheet" href="templates/siteground-j16-10/css/template_2.css" type="text/css" />




    <link rel="stylesheet" href="templates/siteground-j16-10/css/colorbox.css" type="text/css"/>

  
  
     <script type="text/javascript" src="templates/siteground-j16-10/js/jquery.min.js"></script>
     <script type="text/javascript" src="templates/siteground-j16-10/js/jquery.colorbox.js"></script>


     <script src="templates/siteground-j16-10/js/main.js"></script>
<!--<script>
      function openColorBox(){
		  //กำหนดขนาดและหน้าเว็บที่จะแสดงใน popup สามารถใส่เป็นภาพก็ได้นะครับ
        $.colorbox({iframe:true, width:"720px", height:"969px", href: "templates/siteground-j16-10/images/op2.jpg"});
      }
      
      function countDown(){
        seconds--
        $("#seconds").text(seconds);
        if (seconds === 0){
          openColorBox();
          clearInterval(i);
        }
      }
      //กำหนดเวลา วินาทีที่จะให้ popup ทำงาน 
      var seconds = 2,
          i = setInterval(countDown, 1000);
    </script>-->


<script language="javascript">
function fncSubmit()
{
	if(document.form1.chk1.checked == false)
	{
		alert('Please Click Checkbox');
		return false;
	}	

	document.form1.submit();
}
</script>



</head>


<body class="page_bg">


	<div class="wrapper">


   






	


<section id="content">

	<div id="headerwrapper">
	      <p> โรงพยาบาลบางบ่อ(Bangbohospital)</p>
	</div>
    <div class="maincol">
		
          <div>
            <p>dddddddddd</p>
            <p>&nbsp;</p>
            <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" onSubmit="JavaScript:return fncSubmit();">
              <table width="567" align="center">
                <tr valign="baseline">
                  <td width="137" align="right" nowrap="nowrap"><strong>Name   (ชื่อภาษาไทย)* </strong>:</td>
                  <td width="342"><input type="text" name="name_th" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Name (ชื่อภาษาอังกฤษ)* </strong>:</td>
                  <td><input type="text" name="name_en" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>CID (เลขบัตรประชาชน.)*</strong>:</td>
                  <td><input name="cid" type="text" value="" size="32" maxlength="13" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Nationality (สัญชาติ)*:</strong></td>
                  <td><input name="natity" type="text" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Gender(เพศ)</strong>*:</td>
                  <td valign="baseline"><table width="113">
                    <tr>
                      <td width="90"><input type="radio" name="gen" value="Male" />
                        Male(ชาย)</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="gen" value="Fmale" />
                        Fmale(หญิง) </td>
                    </tr>
                  </table></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>BirthDate(วันเกิด)</strong>*:</td>
                  <td><input type="text" name="bri_day" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Age (อายุ)</strong>*:</td>
                  <td><input type="text" name="age" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Blood Type (กรุ๊ปเลือด</strong>)*:</td>
                  <td valign="baseline"><table width="48">
                    <tr>
                      <td><input type="radio" name="blood_type" value="A" />
                        A</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="blood_type" value="AB" />
                        AB</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="blood_type" value="B" />
                        B</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="blood_type" value="O" />
                        O</td>
                    </tr>
                  </table></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Phone (โทรศัพท์)</strong>*:</td>
                  <td><input type="text" name="phone" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>โรคประจำตัว</strong>*:</td>
                  <td><input type="text" name="con_dise" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>ชื่อผู้ติดต่อกรณีฉุกเฉิน*:</strong></td>
                  <td><input type="text" name="name_con" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>เบอร์โทรศัพทกรณีฉุกเฉิน*:</strong></td>
                  <td><input type="text" name="tel_con" value="" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>เลือกระยะวิ่ง*:</strong></td>
                  <td valign="baseline"><table width="158">
                    <tr>
                      <td><input type="radio" name="categry" value="10km" />
                        Minimarathon 10 km.</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="categry" value="4km" />
                        เดิน-วิ่ง 4 km</td>
                    </tr>
                  </table></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"><strong>Preferred Shirt Size (ขนาดเสื้อที่ต้องการ)* </strong>:</td>
                  <td valign="baseline"><table>
                    <tr>
                      <td width="120"><input type="radio" name="t_shirt" value="XS" />
                        XS  24&quot;  ยาว 20&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="S" />
                        S   38&quot;  ยาว 21&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="M" />
                        M   40&quot;  ยาว 28&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="L" />
                        L  42&quot;   ยาว 29&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="XL" />
                        XL  44&quot;   ยาว 30&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="2XL" />
                        2XL 46&quot;  ยาว 31&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="3XL" />
                        3XL 48&quot;  ยาว 32&quot;</td>
                    </tr>
                    <tr>
                      <td><input type="radio" name="t_shirt" value="4XL" />
                        4XL 50&quot;  ยาว 33&quot;</td>
                    </tr>
                    
                    <tr>
                      <td><input type="radio" name="t_shirt" value="5XL" />
                        5XL 52&quot;  ยาว 33&quot; </td>
                    </tr>
                  </table></td>
                </tr>
                <tr valign="baseline">
                  <td colspan="2" align="center"  nowrap="nowrap">
                    
                      <textarea name="textarea" cols="90" rows="25" readonly="readonly" id="textarea" 
                      > <strong>คำรับรองผู้สมัคร RUNNING EVENT WAIVER FORM(Signature required)</strong>
I know that running is a potentially hazardous activity, which could cause injury or death. I should not enter and run unless I am medically able and properly trained. I agree to abide by any decision of a race official relative to my ability to safely complete the run. I hereby certify that I am in good health and I have trained to run the distance of the race, which I am entering. I assume all risks associated with running in this event including, but not limited to: falls, contact with other participants, the effects of weather, including high heat and/or humidity, traffic and the conditions of the road, all such risks being known and appreciated by me. Having read this waiver and knowing these facts and in consideration of your accepting my entry into this running race, I, for myself and anyone entitled to act on my behalf, waive and release “BangBo Mini Marathon 2018”, Inc., its officers, directors, agents, volunteers and employees, all states, cities, counties, the Metropolitan District Commission or other governmental bodies or locations in which events or segments of events are held, all sponsors, their representatives and successors, from all claims or liabilities of any kind arising out of my participation in this event even though that liability may arise out of negligence or carelessness on the part of the persons named in this waiver. I hereby agree that in the event of the event being cancelled in whole or in part due to wind, storm, rain inclement seas or weather or other condition, my entry fee shell not be refundable. I grant permission to all of the foregoing to use any photographs, motion pictures, recordings, or any other record of this event for any legitimate purpose.</textarea>
                   
                  </td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">&nbsp;</td>
                  <td><input type="submit" value="Insert record" name="MM_insert2" />                    <input name="chk1" type="checkbox" id="chk1" value="Y"/>
                 </td>
                </tr>
              </table>
              <input type="hidden" name="MM_insert" value="form1" />
            </form>
            <p>&nbsp;</p>
          </div>
          

          
          
      <div class="footer">

		
                     </p>

         </div>
  
         <div class="sup"> Engine By Powered by: Wasu </div>

  </div>


</section>

</div>
 
</body>




</html>
<?php
mysql_free_result($run);
?>





Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2018-09-20 10:14:33 By : ounamo View : 571 Reply : 1
 

 

No. 1



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



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

เอา id ใส่ลงไปใน input เวลา submit ก็จะส่งไปพร้อมกันครับ
แต่ถ้าต้องการ redirect หลังบันทึกเสร็จ ก็ใช้ javascript redirect พ่วงท้ายด้วย mysql_insert_id();

Last insert ID and redirect
https://forums.phpfreaks.com/topic/186169-last-insert-id-and-redirect/






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2018-09-20 11:08:34 By : {Cyberman}
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
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 02
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 อัตราราคา คลิกที่นี่