Guest User

Untitled

a guest
Feb 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php //open php
  2. include "../includes/head3.php";
  3. ?>
  4.  
  5. <a href=<?=$_SERVER['PHP_SELF']?>?adds=1>[Add Log Entry]</a>
  6.  
  7. <?php
  8. //------------------------------------------
  9. // DELETE FUNCTIONS
  10. //------------------------------------------
  11. if (isset($_GET['del'])) {
  12. if ($change == add){
  13. $OldAmount -= $Amount;
  14. }
  15. else {
  16. $OldAmount += $Amount;
  17. }
  18. mysql_query("DELETE from APSLOG where ID='" . $_GET['del'] . "'");
  19. echo "<br>Record deleted!<br>";
  20. }
  21.  
  22. //------------------------------------------
  23. // ADD FUNCTIONS
  24. //------------------------------------------
  25. if (isset($_GET['adds'])) {
  26.  
  27. echo '<form action=' . $_SERVER['PHP_SELF'] . ' method="post">';
  28. echo 'Username: <input type="text" name="Name"/>';
  29. echo 'User ID: <input type="text" name="UserID"/>';
  30. echo 'Old Amount: <input type="text" name="OldAmount"/>';
  31. echo 'Point Change: <select name="change"/>';
  32. echo '<option value="add">Add</option>';
  33. echo '<option value="sub">Subtract</option>';
  34. echo '<input type="text" name="Amount"/>';
  35. echo 'Description: <input type="text" name="Description"/>';
  36. echo '<input type="hidden" value="ID" name="ID"/>';
  37. echo '<input type="submit" value="Add" name="addit"/>';
  38. echo '</form>';
  39.  
  40. }
  41.  
  42. if (isset($_POST['addit'])) {
  43. $Name=$_POST['Name'];
  44. $Name=strip_tags($Name);
  45. $UserID=$_POST['UserID'];
  46. $OldAmount=$_POST['OldAmount'];
  47. $change=$_POST['change'];
  48. $Amount=$_POST['Amount'];
  49. $Description=$_POST['Description'];
  50.  
  51. if ($change == add){
  52. $OldAmount += $Amount;
  53. }
  54.  
  55. If ($change == sub){
  56. $OldAmount -= $Amount;
  57. }
  58.  
  59. mysql_query("INSERT INTO APSLOG (Amount = Amount + '$change' where UserID = '$UserId')");
  60. }
  61.  
  62.  
  63.  
  64. //------------------------------------------
  65. // DISPLAY FUNCTIONS
  66. //------------------------------------------
  67.  
  68. $result = mysql_query("SELECT * FROM APSLOG ORDER BY ID DESC");
  69.  
  70. if (mysql_num_rows($result) > 0) {
  71. echo '<table border=1><tr><td><center>Name</center></td><td><center>Change</center></td><td><center>Description</center></td></tr>';
  72. while($row = mysql_fetch_array($result));
  73. {
  74. echo "<tr><td width=150>" . $row['Name'] . "</td><td width=100>" . $row['change'] . "" . $row['Amount'] . "</td><td width=600>" . $row['Description'] . "</td><td width=150><a href=" . $_SERVER['PHP_SELF'] . "?del=" . $row['ID'] . ">Delete</a></td></tr>";
  75. }
  76. mysql_free_result($result);
  77. }
  78. mysql_close($con);
  79. include "../includes/foot.php";
  80. ?>
Add Comment
Please, Sign In to add comment