3
這是我第一次嘗試使用oracle數據庫。 我嘗試爲我的項目創建一些更新表單,但是當我單擊更新按鈕時它不會更新。但是如果它有效,在我們按下更新按鈕後,它會顯示在另一個頁面上,但在另一個頁面上它根本不會改變。我找不到這些信息。我希望有人能幫助我。無法更新php&oracle
對不起,我的英語不好。
<?php
include 'ora_connect.php';
if (isset($_POST['Update'])) {
$id = $_POST['ID'];
$nama = $_POST['NAMA'];
$departemen = $_POST['DEPARTEMEN'];
$username = $_POST['USERNAME'];
$password = $_POST['PASSWORD'];
$status = $_POST['STATUS'];
$sql = "UPDATE wlan_user SET USERNAME='$username',PASSWORD='$password',NAMA='$nama',STATUS='$status' WHERE ID=$id";
header("Location: index.php?page=monitoring");
}
$sqlparse =oci_parse($conn,$sql);
$result=oci_execute($sqlparse) or die(oci_error());
?>
<?php
$id = isset($_GET['ID']) ? $_GET['ID'] : '';
$query = "SELECT * FROM wlan_user WHERE ID=$id";
$statmen = oci_parse($conn, $query);
oci_execute($statmen, OCI_DEFAULT);
while ($res = oci_fetch_array($statmen, OCI_BOTH))
{
$nama = $res['NAMA'];
$departemen = $res['DEPARTEMEN'];
$username = $res['USERNAME'];
$password = $res['PASSWORD'];
$status = $res['STATUS'];
}
?>
<form name="form1" method="post">
<table border="0">
<tr>
<td>Nama</td>
<td><input type="text" name="nama" value=<?php echo "'$nama'"; ?>></td>
</tr>
<tr>
<td>Departemen</td>
<td><input type="text" name="departemen" value=<?php echo $departemen; ?>></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="username" value=<?php echo "'$username'"; ?>></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" value=<?php echo $password; ?>></td>
</tr>
<tr>
<td>Status</td>
<td><input type="radio" name="type" value="A" checked>A<br><input type="radio" name="type" value="B">B<br><input type="radio" name="type" value="C">C</td>
</tr>
<tr>
<td><input type="hidden" name="id" value=<?php echo $_GET['id']; ?>></td>
<td><input type="submit" name="Update" value="Update"></td>
</tr>
</table>
</form>
我不是那麼好的php,但爲什麼你不添加檢查,如果連接成功或沒有,這是正確的'WHERE ID = $ id'?你應該在旁邊添加引號嗎? – Moudiz
你從哪裏得到$ conn? –
@AchinthaGunasekara它來自我的ora_connect.php – Albanna