sempreexe Posted January 19, 2008 Share Posted January 19, 2008 I'm trying to delete 1 SQL record with a confirmation page and on confirmation send me to a specified page. The record deletes on clicking the yes button for confirmation but I still get the confirmation buttons in the next window, is there a possibility so I get to a specified webpage instead? The image is when I confirmed to delete [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/ Share on other sites More sharing options...
sempreexe Posted January 19, 2008 Author Share Posted January 19, 2008 and here is my missing code of course: <?php $host="localhost"; $username="root"; $password="***"; $fout="ERROR"; $dbnaam="nieuws"; $db=mysql_connect($host, $username, $password) or die (mysql_error()); mysql_select_db($dbnaam, $db) or die (mysql_error()); if (isset($_POST['bevestiging'])) { $query="DELETE FROM nieuwsitems WHERE ID=".$_POST['ID']; $result=mysql_query($query,$db)or die($fout); echo ("Dit is uitgevoerd $query"); if($result) { echo ("ID= ".$_POST['ID']."is verwijderd"); } } else { $query="SELECT * FROM nieuwsitems WHERE ID=".$_GET["ID"]; $result=mysql_query($query,$db) or die($fout); } ?> <html> <body> <?php while ($rij=mysql_fetch_array($result)) { echo("ID = " . $rij['ID'] . "<br>\n"); echo("Nieuws = ". $rij['nieuws'] ."<br>\n"); echo("Datum = ". $rij['datum'] . "<br><br>\n"); }?> Ben je zeker dat deze nieuwsitem verwijderd mag worden?<br> <form action="<?php echo($_SERVER["PHP_SELF"]);?>" method="post"> <input type="hidden" name="bevestiging" value="1"> <input type="hidden" name="ID" value="<?php echo($_GET["ID"]);?>"> <input type="Submit" value="Ja"> <input type="Button" value="Nee" onclick="javascript:history.back();"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/#findComment-443675 Share on other sites More sharing options...
sempreexe Posted January 20, 2008 Author Share Posted January 20, 2008 anyone? ??? Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/#findComment-444235 Share on other sites More sharing options...
ratcateme Posted January 20, 2008 Share Posted January 20, 2008 i don't understand the language you are using but it looks to me like you are trying to fetch the array of a DELETE FROM query which is impossible because DELETE query's return nothing you need to remove the else on line 19 so a SELECT query is done every time. Scott Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/#findComment-444244 Share on other sites More sharing options...
budimir Posted January 20, 2008 Share Posted January 20, 2008 Hey there, You can use: header ("Location:your_location.php"); But, be carefull. You can't have any output before header otherwise you'll end up with an error. Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/#findComment-444253 Share on other sites More sharing options...
sempreexe Posted January 20, 2008 Author Share Posted January 20, 2008 that was the solution, thanks budimir Quote Link to comment https://forums.phpfreaks.com/topic/86802-solved-problem-deleting-sql-record-with-php/#findComment-444257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.