Guest User

Untitled

a guest
Jun 9th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. //DB login info
  2. $dbUsername = 'changed';
  3. $dbPassword = 'changed';
  4. $qdb = "ttk_qdb";
  5. $addlike = $_POST['curlike'] + 1;
  6. $addhate = $_POST['curhate'] + 1;
  7.  
  8. if ($_SESSION['login'] != "yes")
  9. {
  10. echo('You must login to use this function.');
  11. }
  12. elseif ($_POST['rate'] == "")
  13. {
  14. echo "You didn't vote!";
  15. }
  16. elseif ($_POST['rate'] == "Hate")
  17. {
  18. echo 'Submiting your vote...';
  19. $ttkqdb = mysql_connect("localhost", $dbUsername, $dbPassword);
  20.  
  21. if (!$ttkqdb)
  22. {
  23. echo('Error, unable to connect to the database');
  24. }
  25.  
  26. mysql_select_db($qdb, $ttkqdb);
  27.  
  28. mysql_query("UPDATE `quotes` SET `hate` = '".$addhate."' WHERE id = '".$_POST['postid']."'") or die(mysql_error());
  29. mysql_close($ttkqdb);
  30. }
  31. elseif ($_POST['rate'] == "Like")
  32. {
  33. echo 'Submiting your vote...';
  34. $ttkqdb = mysql_connect("localhost", $dbUsername, $dbPassword);
  35.  
  36. if (!$ttkqdb)
  37. {
  38. echo('Error, unable to connect to the database');
  39. }
  40.  
  41. mysql_select_db($qdb, $ttkqdb);
  42. mysql_query("UPDATE `quotes` SET `like` = '".$addlike."' WHERE id = '".$_POST['postid']."'") or die(mysql_error());
  43. mysql_close($ttkqdb);
  44. }
Add Comment
Please, Sign In to add comment