Advertisement
Guest User

Untitled

a guest
Jan 30th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. if($user == $me){
  2. $sql_delete = "DELETE FROM replys WHERE id = '$id' AND rusername = '$me'";
  3. echo $sql_delete;
  4. mysql_query($sql_delete) or die(mysql_error());
  5. echo "Deleted";
  6. }
  7. else{
  8. }
  9. }
  10. ?>
  11.  
  12. <?php
  13. session_start();
  14. if(isset($_POST['DeleteThis'])){
  15.  
  16. $db_host = "localhost";
  17. $db_user = "root";
  18. $db_pass = "kindom";
  19. $db_name = "posters";
  20.  
  21. try {
  22. $user = $_SESSION['username'];
  23. $form = $_POST;
  24. $id = $form['id']);
  25. $me = $form['me'];
  26. if($me == $user){
  27. $db_conn = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
  28. $db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  29.  
  30. $stmt = $db_conn->prepare("DELETE FROM replys WHERE id = :id AND rusername = :user");
  31.  
  32. //I have tried using this SQL statements
  33. //$query = "DELETE FROM replys WHERE id = {$id} AND rusername = {$user}";
  34. //$query = "DELETE * FROM replys WHERE id = :id AND rusername = :rusername";
  35. $query = "DELETE FROM replys WHERE id = :id AND rusername = :rusername";
  36.  
  37. $stmt->bindParam(':id', $id);
  38. $stmt->bindParam(':rusername', $user);
  39.  
  40. $stmt->execute();
  41. echo "Deleted";
  42. }
  43. else{
  44. //Do nothing
  45. }
  46. }
  47. catch(PDOException $e)
  48. {
  49. echo "Error:" . $e->getMessage();
  50. }
  51. $db_conn = null;
  52. }
  53. ?>
  54.  
  55. <a href="javascript:void(0);" onclick="document.getElementById('deleterp').submit();"><i style="font-size:17px;color:#F00;" class="fa fa-trash"></i></a>
  56. <form id="deleterp" action="" method="POST">
  57. <input type="hidden" name="id" value="<?php echo $rpId;?>"/>
  58. <input type="hidden" name="DeleteThis" value="1"/>
  59. <input type="hidden" name="me" value="<?php echo $rplyuser;?>"/>
  60. </form></div>
  61.  
  62. $stmt = $db_conn->prepare("DELETE FROM replys WHERE id = :id AND rusername = :rusername");
  63.  
  64. $stmt = $db_conn->prepare("DELETE FROM replys WHERE id = :id AND rusername = :user");
  65.  
  66. <?php
  67. .
  68. .
  69. $stmt = $db_conn->prepare("DELETE FROM replys WHERE id = :id AND rusername = :rusername");
  70. $stmt->bindParam(':id', $id);
  71. $stmt->bindParam(':rusername', $user);
  72. .
  73. .
  74. ?>
  75.  
  76. $id = $form['id']);
  77.  
  78. $id = $form['id'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement