Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost"; // Host name
- $username="XXX"; // Mysql username
- $password="XXX"; // Mysql password
- $db_name="XXX"; // Database name
- $tbl_name="messages"; // Table name
- // Connect to server and select database.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $sql="SELECT * FROM $tbl_name where id='".$_GET[id]."' "; //
- $result=mysql_query($sql) or die(mysql_error()); // Getting image name from database so that we can delete it
- $fetch=mysql_fetch_assoc($result); //
- $image=$fetch[image]; //
- $sql="DELETE from $tbl_name where id='".$_GET[id]."' "; // Deleting from database based on ID that is located in $_GET[id] variable that was passed in url like this : delete.php?id=
- mysql_query($sql) or die(mysql_error());
- @unlink("upload/".$image); // Deleting image .. @ infront means if there is some warning like "file doesn't exist, to surpress it
- @unlink("upload/thumb_".$image); // Deleting Thumb image .. @ infront means if there is some warning like "file doesn't exist, to surpress it
- header("location:messageboard.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement