This is the first time I try to use oracle database. I try to create some update form for my project, but when I click the update button it won't update. But if it works, after we push the update button it will show on another page but on that another page it doesn't change at all. I can't find the information. I hope that somebody can help me.
Sorry for my bad English.
<?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>
Your if (isset($_POST['Update'])) { } never executes, because in your form no input variable Update. Submit button not variable. Add to your form
<input type="hidden" name="Update" value="my_update_flag">