我想開發一個包含兩個窗體的網頁,當頁面加載時只顯示第一個窗體並填充後,第二個窗體根據用戶的需求顯示,兩個窗體的值將被存儲在數據庫的兩個不同的表中我不知道這背後的邏輯是什麼。 PLZ給我建議的解決方案和示例link.thankyou 之前,這是我的代碼只是爲了顯示一種形式,但第二個有相同的圖案如何顯示和隱藏網頁上的表格?我可以做到這一點與PHP?
<!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">
<?php
if (!empty($_POST['det_loc'])) {
//do something here;
mysql_connect("localhost","root");//database connection
mysql_select_db("admin");
//inserting data into DET_LOCATION Table
$locID=$_POST["LocID"];
$latitude=$_POST["Latitude"];
$longitude=$_POST["Longitude"];
$store = "INSERT INTO det_location(LocID,Latitude,Longitude) VALUES('$locID','$latitude','$longitude')";
//declare in the order variable
$result = mysql_query($store); //order executes
if($result)
{
echo "<br>Input data is succeed";
} else{
echo "<br>Input data is fail";
}
}
if (!empty($_POST['more_loc'])) {
//do something here;
mysql_connect("localhost","root");//database connection
mysql_select_db("admin");
//inserting data into DET_LOCATION Table
$latitude=$_POST["Latitude"];
$longitude=$_POST["Longitude"];
$store = "INSERT INTO det_location(Latitude,Longitude) VALUES('$latitude','$longitude')";
//declare in the order variable
$result = mysql_query($store); //order executes
if($result)
{
echo "<br>All data is Entered";
} else{
echo "<br>Input data is fail";
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Input Detail Location</title>
</head>
<body>
<table border="1">
<tr>
<td align="center">Det_Location</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="det_loc">
<tr>
<td>locID</td>
<td><input type="Integer" name ="LocID" size="20">
</td>
</tr>
<tr>
<td>Latitude</td>
<td><input type="Float" name ="Latitude" size="20">
</td>
</tr>
<tr>
<td>Longitude</td>
<td><input type="Float" name="Longitude" size="20">
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<input type="submit" name="det_loc" value="Add more" />
</td>
</tr>
</table>
<table border="1">
<tr>
<td align="center">More Locations</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="">
<tr>
<td>Latitude</td>
<td><input type="Float" name ="Latitude" size="20">
</td>
</tr>
<tr>
<td>Longitude</td>
<td><input type="Float" name="Longitude" size="20">
</td>
</tr>
<tr>
<td>Latitude</td>
<td><input type="Float" name ="Latitude" size="20">
</td>
</tr>
<tr>
<td>Longitude</td>
<td><input type="Float" name="Longitude" size="20">
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<input type="submit" name="more_loc" value="Send Data" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
,但在同一個頁面上同時顯示錶和犯規發送數據到mysql數據庫。
您有一個SQL注入漏洞。 – SLaks 2013-04-03 19:42:11
php不能「隱藏」任何東西,除非它不是首先輸出表單。你有PHP輸出一些CSS,一旦它在客戶端上呈現就可以隱藏表單。樣式指令或內聯'... style =「display:none」'。 – 2013-04-03 19:42:24
[請不要在新代碼中使用'mysql_ *'函數](http://stackoverflow.com/q/12859942/1190388)。他們不再被維護,並[正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到紅色框?改爲了解準備好的語句,然後使用[tag:PDO]或[tag:MySQLi]。 – hjpotter92 2013-04-03 19:43:00