i have problem with my delete query i have 3 php file first one name : bordel.php <?php /* Program name: bordel.php * Description: Program builds a selection list * from the database to select the borrower to delete. */ ?> <html> <head><title>Delete Borrower</title></head> <body bgcolor="#F5F5F5" > <font color= "#000099" face="Garamond"> <b><h2>Select the Borrower You Want to Delete from the Database:</h2><br>
<?php $user="root"; $host="localhost"; $password=""; $database = "joomla15";
$cxn = mysqli_connect($host,$user,$password,$database) or die ("couldn't connect to server"); $query = "SELECT DISTINCT borrower_name FROM borrower ORDER BY borrower_name"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query.");
/* create form containing selection list */ echo "<form action='deleteborrower.php' method='POST'> <select name='borrower_name'>\n";
while ($row = mysqli_fetch_assoc($result)) { extract($row); echo "<option value='$borrower_name'>$borrower_name\n"; } echo "</select>\n"; echo "<input type='submit' value='Select Borrower to Delete'> </form>\n"; ?> </body></html>
------------------------------------------------------------------------- second php file
<!- Program name: deleteborrower.php Description: Script displays a form to edit the borrower> <html> <head><title>Edit Selected Borrower</title></head> <body bgcolor="#F5F5F5"> <font color= "#000099" face="Garamond" size="18"><b> <?php
$labels = array( "borrowerID"=>"ID:", "borrower_name"=>"Name:", "borrower_phone"=>"Phone:", "borrower_email"=>"Email:", "borrower_lateTime"=>"Late on return times:", "borrower_status"=>"Status:"); $user="root"; $host="localhost"; $password=""; $database = "joomla15"; foreach ($_POST as $field => $value)
$cxn = mysqli_connect($host,$user,$password,$database) or die ("couldn't connect to server"); $query = "SELECT * FROM borrower WHERE borrower_name='$value'";
$result = mysqli_query($cxn,$query) or die ("Couldn't execute query");
echo "<p style='font-size: large; font-weight: bold'> Are You Sure You Want to Delete $value 's Information ?</p><hr />";
$query="SELECT * FROM borrower WHERE borrower_name= '$_POST[borrower_name]'"; $result=mysqli_query($cxn,$query) or die("Couldn't execute query");
/* Display results in a table */ echo "<table cellspacing='10'>"; echo "<td><b><u>ID</td> <td><b><u>Name</td> <td><b><u>Phone</td> <td><b><u>Email</td> <td><b><u>Late </td>
<td><b><u>Status</td>"; echo "<tr><td colspan='10'><hr/></td></tr>"; while($row = mysqli_fetch_assoc($result)) {
extract($row); echo "<tr>\n <td>$borrowerID</td>\n <td>$borrower_name</td>\n <td>$borrower_phone</td>\n <td>$borrower_email</td>\n <td>$borrower_lateTime time(s) </td>\n <td>$borrower_status</td>\n </tr>\n"; echo "<tr><td colspan='10'><hr /></td></tr>\n"; } echo "</table>\n";
echo "<form action='processform1.php' method='POST'> <p><table align='left'>\n";
echo "<tr><td> </td> <td style='text-align: left' > <input type='submit' value='Yes'>"; echo "</td></tr></table> </div> </form>";
?> </body></html>
--------------------------------------------------------- 3rd php file proccessform.php
<html> <head><title>borrower</title></head> <body bgcolor="#F5F5F5"> <font color= "#000099" face="Garamond"> <?php $user="root"; $host="localhost"; $password=""; $database ="joomla15";
foreach ($_POST as $field => $loving)
$cxn = mysqli_connect($host,$user,$password,$database) or die ("couldn't connect to server");
echo $sql;// this is the query variable
$query = "DELETE FROM borrower WHERE borrower_name='$POST'[borrower_name]'" ;
mysqli_query($cxn, $query) or die ("Couldn't execute query");
echo "<h2>Borrower Is Deleted!</h2>";
?> </body></html>
-------------------------------------------------------------------
it gave me an answer your borrower has been deleted but its fake because i found that nothing has been deleted !! what i should do ? what is the problem with my scripts?
|
|