Re: PHP Delete confirmation
| From: | B. Aerts | Date: | Fri, 29 Apr 2011 07:02:09 +0000 |
| Subject: | Re: PHP Delete confirmation | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-47778@lists.php.net to get a copy of this message | ||
You could try to reload the same page, but with an added GET-parameter "delete":
I assume your snippet comes from a script called MAIN.PHP :
<?php
if ( $_GET["delete"] == "yes" ) {
$id = $_GET["id"] ;
echo "<DIV> ARE YOU SURE ? <A HREF="delete.php?id=$id">yes</A></DIV>" ;
}
while($row = mysql_fetch_array( $result )) {
// rest of your snippet
echo '<td>'
echo '<a href="MAIN.PHP?id='.$row['id'].'&delete=yes">Delete</a>';
echo '</td>';
}
// and so on
If your code below doesn't detect the GET-parameter "delete", it does what you have now.
If it does detect the parameter, you show a DIV with all formatting and buttons you want to confirm or abort the delete action.
I've left out some of the parameter checking for clarity.
Why would you want to avoid Javascript ?
Bert
On 29/04/11 06:20, Chris Stinemetz wrote:
I have been trying to figure out how to add delete confirmation for the bellow snippet of code. I would prefer not to use javascript. Can anyone offer any advise on how to right the delete confirmation in PHP? Thank you in advance. P.S. I apologize for the indention. For some reason gmail messes it up. <?php// loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) {// echo out the contents of each row into a table echo "<tr>"; echo '<td>' . $row['Name'] .'</td>'; echo '<td>' . $row['Date'] .'</td>'; echo '<td>' . $row['StoreInfo'] .'</td>'; echo '<td>' . $row['Address'] .'</td>'; echo '<td>' . $row['Type'] .'</td>'; echo '<td>' . $row['EngTech'] .'</td>'; echo '<td>' . $row['StoreManager'] .'</td>'; echo '<td>' . $row['BBtime'] .'</td>'; echo '<td>' . $row['BBup'] .'</td>'; echo '<td>' . $row['BBdown'] .'</td>'; echo '<td>' . $row['SiteSect'] .'</td>'; echo '<td>' . $row['VoiceCall'] .'</td>'; echo '<td>' . $row['Comments'] .'</td>'; echo '<td><a href="edit.php?id=' . $row['id'].'">Edit</a></td>';echo '<td><a href="delete.php?id=' . $row['id'].'">Delete</a></td>';echo "</tr>"; }// close table> echo "</table>";?>