Sorry, again i'm having a problem with my coding. These codes for my delete data page. Here's the codes :
<?php
// This page deletes laporan
// This page is accessed through view.php
$page_title = 'e-DAMAGE - Padam Laporan ?';
// Check for a valid id, through GET or POST
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view.php
$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
$id = $_POST['id'];
} else { // No valid ID, kill the script.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
exit();
}
include_once ('dbconnect.php'); // Connect to the database.
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
if($_POST['sure'] == 'Yes') { // Delete them.
// Make the query.
$query = "DELETE FROM damage_tb WHERE id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
// Print a message.
echo '<h1 id="mainhead">Padam Laporan!</h1>
<p>Laporan telah dipadamkan.</p><p><br /><br /></p>';
} else { // If the query did not run OK.
echo '<h1 id="mainhead">System Error</h1>
<p class="error">Laporan tidak dapat dipadamkan kerana ada ralat pada sistem.</p>'; // Public message.
echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message
}
} else { // Wasn't sure about deleting laporan.
echo '<h1 id="mainhead">Padam Laporan</h1>
<p>Laporan tidak dipadamkan.</p><p><br /></p>';
}
} else { // Show the form.
// Retrieve maklumat laporan.
$query = "SELECT CONCAT(nama, ',' , no_kp , ',' , telefon , ',' , email , ',' , masalah) FROM damage_tb WHERE id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_num_rows($result) == 1) { // Valid ID, show the form.
// Get the laporan maklumat.
$row = mysql_fetch_array ($result, MYSQL_NUM);
// Create the form.
echo '<title>e-DAMAGE - Padam Laporan</title><h2>e-DAMAGE - Padam Laporan</h2>
<form action="padam.php" method="post">
<h3>Name : ' . $row[0] . '</h3>
<p>Adakah anda pasti ingin PADAMKAN laporan ini ?<br />
<input type="radio" name="sure" value="Yes" /> Yes
<input type="radio" name="sure" value="No" checked="checked" /> No</p>
<p><input type="submit" name="Submit" value="Submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value=' . $id . '" />
</form>';
} else { // Not a valid ID.
echo '<h1 id="mainhed">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}
} // End of the main Submit conditional/
mysql_close(); // Close the database connection.
?>
When i execute this page, i always get this error message :
Page Error
This page has been accessed in error.
Whats happenning? can anybody tell me how i can fix this codes? 😕