|
|
|
ขอโค้ดเมื่อเรากรอกข้อมูลเสร็จแล้วกดตกลงให้แสดงขอมูลที่เรากรอกหน่อยคับ |
|
|
|
|
|
|
|
Code (PHP)
if($_POST['submit']){
var_dump($_POST);
}
//หรือ
if($_POST['submit']){
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
|
|
|
|
|
Date :
2012-03-02 22:56:19 |
By :
thaicloud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องนำไปวางไว้ตรงไนคับ
|
|
|
|
|
Date :
2012-03-02 22:58:47 |
By :
บี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้าที่ คุณตั้งค่าไว้ใน action ครับ
<form action='' mehod=''post>
ถ้าเขียนอย่างนี้ก็เอาไว้ข้างบนสุดครับ
Code (PHP)
if($_POST['submit']){
var_dump($_POST);
}
<form action='' mehod=''post>
<inptut type='submit' name='submit'/>
</form>
|
|
|
|
|
Date :
2012-03-02 23:08:22 |
By :
thaicloud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่คับรบกวนนำไปวางให้ผมหน่อยคับผมทำแล้วมันไม่ได้คับ
<?php require_once('Connections/dbcon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "fmAdd")) {
$insertSQL = sprintf("INSERT INTO disbursement (`date`, `month`, `year`, name, lastname, `order`, code, name_m, category, `number`, unit, tote) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['date'], "int"),
GetSQLValueString($_POST['month'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['lastname'], "text"),
GetSQLValueString($_POST['order'], "int"),
GetSQLValueString($_POST['code'], "text"),
GetSQLValueString($_POST['name_m'], "text"),
GetSQLValueString($_POST['category'], "text"),
GetSQLValueString($_POST['number'], "text"),
GetSQLValueString($_POST['unit'], "text"),
GetSQLValueString($_POST['tote'], "int"));
mysql_select_db($database_dbcon, $dbcon);
$Result1 = mysql_query($insertSQL, $dbcon) or die(mysql_error());
$insertGoTo = "raw_1.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>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #9933CC}
.style2 {
font-family: "Angsana New";
font-size: 20px;
}
.style3 {font-size: 18px}
.style4 {font-family: "Angsana New"}
.style6 {
font-family: "Angsana New";
font-size: 24px;
font-weight: bold;
}
-->
</style>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="fmAdd" name="fmAdd" method="POST" action="<?php echo $editFormAction; ?>">
<table width="800" border="0" align="center">
<tr>
<td colspan="2" align="center"><span class="style6">ใบเบิกวัตถุดิบ</span></td>
</tr>
<tr>
<td colspan="2" align="center" class="style6"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="711"><span class="style2">วันที่ : <span class="style1">
<select name="date" id="date">
<option>วัน</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</span>
<select name="month" id="month">
<option>เดือน</option>
<option value="01">มกราคม</option>
<option value="02">กุมภาพันธ์</option>
<option value="03">มีนาคม</option>
<option value="04">เมษายน</option>
<option value="05">พฤษภาคม</option>
<option value="06">มิถุนายน</option>
<option value="07">กรกฎาคม</option>
<option value="08">สิงหาคม</option>
<option value="09">กันยายน</option>
<option value="10">ตุลาคม</option>
<option value="11">พฤศจิกายน</option>
<option value="12">ธันวาคม</option>
</select>
<select name="year" id="year">
<option value="">ปี พ.ศ.</option>
<option value="2009">2552</option>
<option value="2010">2553</option>
<option value="2011">2554</option>
<option value="2012">2555</option>
<option value="2013">2556</option>
</select>
</span></td>
<td width="106"> </td>
</tr>
<tr>
<td><span class="style2">ชื่อ :
<input type="text" name="name" id="name" />
นามสกุล :
<input type="text" name="lastname" id="lastname" />
<span id="sprytextfield1"><span class="textfieldRequiredMsg">A value is required.</span></span></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="29" colspan="2" align="left" class="style3 style54"><table width="749" border="1" align="center" bordercolor="#333333">
<tr align="center" class="style2">
<td width="60"><span class="style4">ลำดับ</span></td>
<td width="124"><span class="style4">รหัสหรือเลขที่วัตถุดิบ</span></td>
<td width="225"><span class="style4">รายการวัตถุดิบ</span></td>
<td width="120"><span class="style4">ประเภท</span></td>
<td width="90"><span class="style4">จำนวน</span></td>
<td width="90"><span class="style4">หน่วย</span></td>
</tr>
<tr class="style2">
<td height="145" align="left" valign="top"><textarea name="order" cols="5" rows="20" id="order"></textarea></td>
<td align="left" valign="top"><textarea name="code" cols="20" rows="20" id="code"></textarea></td>
<td align="left" valign="top"><textarea name="name_m" cols="40" rows="20" id="name_m"></textarea></td>
<td align="left" valign="top"><textarea name="category" cols="20" rows="20" id="category"></textarea></td>
<td align="left" valign="top"><textarea name="number" cols="15" rows="20" id="number"></textarea></td>
<td align="left" valign="top"><textarea name="unit" cols="10" rows="20" id="unit"></textarea></td>
</tr>
<tr class="style2">
<td colspan="4" align="center">รวมรายการวัตุถุดิบ</td>
<td colspan="2"><input name="tote" type="text" id="tote" size="15" /></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<input name="Submit" type="submit" id="Submit" value="ตกลง" />
<input type="reset" name="Reset" id="button" value="ยกเลิก" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="fmAdd" />
</form>
</body>
</html>
อันนี้กรอกข้อมูลคับ
<?php require_once('Connections/dbcon.php'); ?>
<?php require_once('Connections/dbcon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$colname_rsEmp = "-1";
if (isset($_GET['id'])) {
$colname_rsEmp = $_GET['id'];
}
mysql_select_db($database_dbcon, $dbcon);
$query_rsEmp = sprintf("SELECT * FROM disbursement WHERE id = %s", GetSQLValueString($colname_rsEmp, "int"));
$rsEmp = mysql_query($query_rsEmp, $dbcon) or die(mysql_error());
$row_rsEmp = mysql_fetch_assoc($rsEmp);
$totalRows_rsEmp = mysql_num_rows($rsEmp);
?><!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #9933CC}
.style2 {
font-family: "Angsana New";
font-size: 20px;
}
.style3 {font-size: 18px}
.style4 {font-family: "Angsana New"}
.style6 {
font-family: "Angsana New";
font-size: 24px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="800" border="0" align="center">
<tr>
<td colspan="2" align="center"><span class="style6">ใบเบิกวัตถุดิบ</span></td>
</tr>
<tr>
<td colspan="2" align="center" class="style6"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="711"><span class="style2">วันที่ :
<?php echo $row_rsEmp['date']; ?>เดือน :<?php echo $row_rsEmp['month']; ?>พ.ศ.<?php echo $row_rsEmp['year']; ?></span></td>
<td width="106"> </td>
</tr>
<tr>
<td><span class="style2">ชื่อ :<?php echo $row_rsEmp['name']; ?> นามสกุล :<?php echo $row_rsEmp['lastname']; ?> </span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="29" colspan="2" align="left" class="style3 style54"><table width="749" border="1" align="center" bordercolor="#333333">
<tr align="center" class="style2">
<td width="60"><span class="style4">ลำดับ</span></td>
<td width="124"><span class="style4">รหัสหรือเลขที่วัตถุดิบ</span></td>
<td width="225"><span class="style4">รายการวัตถุดิบ</span></td>
<td width="120"><span class="style4">ประเภท</span></td>
<td width="90"><span class="style4">จำนวน</span></td>
<td width="90"><span class="style4">หน่วย</span></td>
</tr>
<tr class="style2">
<td align="right"><?php echo $row_rsEmp['order']; ?></td>
<td><?php echo $row_rsEmp['code']; ?></td>
<td><?php echo $row_rsEmp['name_m']; ?></td>
<td><?php echo $row_rsEmp['category']; ?></td>
<td><?php echo $row_rsEmp['number']; ?></td>
<td><?php echo $row_rsEmp['unit']; ?></td>
</tr>
<tr class="style2">
<td colspan="4" align="center">รวมรายการวัตุถุดิบ</td>
<td colspan="2"><?php echo $row_rsEmp['tote']; ?></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><label></label></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($rsEmp);
?>
อันนี้แสดงผลคับ
|
|
|
|
|
Date :
2012-03-02 23:26:13 |
By :
บี |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|