我試圖提交一個表單到同一頁面,所以我想提交數據,然後保存到數據庫中...然後用新數據更新我的頁面...如何將表單發佈到同一個php頁面並攔截它?
我這樣做:
<?php
if (isset($_POST["matricola"]) && isset($_POST["pc"])){
echo "QUI";
$conn = dbConnect($USERDB, $PASSWORDDB, $NAMEDB); //seleziono il database e mi connetto
$matricola = $_POST['matricola'];
$pc = $_POST['pc'];
$queryGetUser = "select id from user where matricola = ".$matricola;
$user = dbQueryGetResult($queryGetUser);
$today = getdate();
$data = $today['mday']."/".$today['month']."/".$today['year'];
$ora = $today['hours'].":".$today['minutes'].":".$today['seconds'];
$sql = "insert into utelenza (id_user, id_pc, dataEntrata, oraEntrata) values (".$user[0].", ".$pc.", ".$data.", ".$ora.")";
dbQueryInsert($sql);
}
//Prendo dal DB le note del laboratorio visualizzabili da tutti
$conn = dbConnect($USERDB, $PASSWORDDB, $NAMEDB);
$queryGetNoteLab = "select noteLaboratorio from laboratorio where id_laboratorio = " . $IDLAB;
$notaLab = dbQueryGetResult($queryGetNoteLab);
$queryGetInfoLab = "select info150ore from laboratorio where id_laboratorio = " . $IDLAB;
$infoLab = dbQueryGetResult($queryGetInfoLab);
$queryGetPcs = "select * from pc where id_laboratorio = " . $IDLAB;
$pcs = dbQueryReturnMatrix($queryGetPcs);
dbDisconnect($conn);
echo "<form action='home150.php' method='post'>"
. "<table><tr><td>Matricola</td><td><input id='matricola' type='text' ></td></tr>"
. "<tr><td>PC</td><td><select id='pc'><option value=''></option>";
for ($i = 0; $i < count($pcs); $i++) {
echo "<option value=" . $pcs[$i][0] . ">" . $pcs[$i][2] . "</option>";
}
echo "</select></td></tr></table>"
. "<input id='submitButton' type='submit' value='Inserisci'></form>";
?>
的形式提交,但提交後我不能截取數據後..
爲什麼?我該如何解決?
謝謝!
第一件事是給了'name'屬性對您的輸入,ID不會讓你在任何地方的服務器端這樣... –