|
 |
|
insert และ action form ในปุ่มเดียวได้หรือเปล่าคะ |
|
 |
|
|
 |
 |
|
จากโค๊ดด้านล่าง
หลังจากที่กดปุ่ม name="submit" แล้ว ให้ทำการ insert ข้อมูลลงฐานข้อมูล
และถ้า insert ข้อมูลลงฐานข้อมูลสำเร็จ ก็ให้ทำการ action form ไปที่ dat.php แบบอัตโนมัติ โดยใช้ค่าในฟอร์ม name="f11"
ไม่ทราบว่าจะสามารถทำได้หรือเปล่าคะ
Code (PHP)
<input type="submit" name="submit"/>
<?PHP
if(isset($_POST["submit"]))
{
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID"]."','".$_POST["txtName"]."','".$_POST["txtEmail"]."' ";
$strSQL .=",'".$_POST["txtCountryCode"]."','".$_POST["txtBudget"]."','".$_POST["txtUsed"]."') ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
?>
<form name="f11" action="dat.php" method="post">
<input type="text" name="note" value="1">
<input type="text" name="first_name" value="<?PHP echo$name; ?>">
<input type="submit" name="submit22" value="ok">
</form>
<?PHP
}
else
{
echo "Error Save [".$strSQL."]";
}
}
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2013-09-20 23:01:44 |
By :
หนูกิ่ง |
View :
1217 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็ทำได้ละครับ ใส่ต่อจาก form
<script>
document.f11.submit();
</script>
แต่สงสัยว่าทำไม่ไม่เอา process ที่อยู่ใน dat.php มาใส่ใน file นี้เลยล่ะครับจะได้ไม่ต้อง submit 2 ที
หรือต้องแยก file ก็ include เข้ามา
Code (PHP)
$_POST[note]=1;
$_POST[first_name]=$name;
$_POST[submit22]='ok';
include('dat.php');
ประมาณนี้ครับ
|
 |
 |
 |
 |
Date :
2013-09-21 01:11:37 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2013-09-21 07:24:24 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|