Advertisement
salehnaveed

Website Delete PHP

Apr 22nd, 2016
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. if( $_SESSION["username"]==""){
  5.  header("Location: http://filewallet.site88.net/");
  6. }
  7. else{
  8.        $servername = "mysql1.000webhost.com";
  9.        $username = "a9691255_naveed";
  10.        $password = "abmirzass123";
  11.        $dbname = "a9691255_webiste";
  12. $userid=$_SESSION["username"];
  13.  
  14. // Create connection
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16. // Check connection
  17. if ($conn->connect_error) {
  18.     die("Connection failed: " . $conn->connect_error);
  19. }
  20.  
  21.  
  22.  
  23. }
  24.  
  25.  
  26.  
  27. $path=$_GET["path"];
  28. $choice=$_GET["choice"];
  29. if($choice==1){
  30. $delete_query="delete from fileuploads where userid= '".$userid."' and filepath ='".$path."'";
  31. if ($conn->query($delete_query) === TRUE) {
  32. unlink($filepath);
  33.     echo "Record deleted successfully";
  34. header("Location: http://filewallet.site88.net/main.php?delfilcheck=1");
  35.  
  36. } else {
  37.     header("Location: http://filewallet.site88.net/main.php?delfilcheck=2");
  38. }
  39.  
  40. $conn->close(); }
  41. else{
  42. if(rmdir($path)){
  43.  
  44. header("Location: http://filewallet.site88.net/main.php?delfolcheck=1");
  45. }
  46. else{
  47. header("Location: http://filewallet.site88.net/main.php?delfolcheck=2");}
  48. }
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement