我試圖將表單中的變量發佈到表單本身。表單裏面有一個iframe,它指向一個php文件(它也包含我需要發佈的元素)。iframe中的PHP POST變量
下面是代碼的摘錄:
//clerkingpatient.php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$con = @pg_connect("host=localhost dbname=datamed user=admin password=admin ");
$name = test_input($_POST["name"]);
$patient_no = test_input($_POST["patientNo"]);
$complains = test_input($_POST["complains"]);
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" target="myframe" onsubmit="return validateForm()" >
<table cellpadding="5">
<tr> <td><input type="text" name="name" value=""/></td> </tr>
<tr> <td><input type="text" name="patientNo" value=""/></td> </tr>
...
...
<tr><td>
<iframe name="myframe" src="ttabcontrol.php" width="1160px" height="200px" frameborder="0"></iframe>
</td> </tr>
<tr><td width="200px"><button type="submit" value="save" style="height: 35px">Save Data</button></td></tr>
</table>
</form>
的抱怨文本字段是ttabcontrol.php
//ttabcontrol.php
<input type="text" name="complains" value="complains"/>
在提交表單我得到這個錯誤「通知:未定義指數:抱怨在C:\ wamp \ www \ bossmed \ clerking \ clerkingpatient.php在線32「 我做錯了,因爲我想使用iframe中的元素。
請告訴我iframe的意義呢? –
您可能需要使用javascript來提交表單,但將操作設置爲iframe而不是將表單提交回同一頁面 – RamRaider
您只需將表單的'action'設置爲'ttabcontrol.php'。不是'PHP_SELF'。另外,你無法通過iframe分割表單。 –