Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. class DBHandler {
  2. public $decryptionKey = "hi";
  3. public $dbhost;
  4. public $dbuser;
  5. public $dbpass;
  6.  
  7. function DBHandler(){
  8. echo $this->decryptionKey;
  9. $this->decryptionKey = "PASSWORD";
  10. echo $this->decryptionKey;
  11. $this->dbhost = 'localhost:3306';
  12. $this->dbuser = 'root';
  13. $this->dbpass = 'password';
  14. }
  15.  
  16. function insertStudent($id, $fName, $lName, $email, $phone){
  17. //connect to database
  18. echo $this->decryptionKey;
  19. echo "hello";
  20. $link = mysqli_connect('localhost:3306', 'root', 'password', "", 3306);
  21.  
  22.  
  23.  
  24.  
  25. echo "world";
  26.  
  27. //define sql code
  28. $sql = "INSERT INTO `Checkout_System`.`STUDENT` " . "(`STUDENT_ID`, `STUDENT_FNAME`, `STUDENT_LNAME`, `STUDENT_EMAIL`, ". "`STUDENT_PHONE`, `STUDENT_OFFENSE_COUNT`) " . "VALUES (" . $id . ", AES_ENCRYPT('" . $fName . "', '" . $this->decryptionKey. "'), AES_ENCRYPT('" . $lName . "', '" . $this->decryptionKey . "'), AES_ENCRYPT('" . $email . "', '" . $this->decryptionKey . "'), AES_ENCRYPT('" . $phone . "', '" . $this->decryptionKey. "'), 0);";
  29.  
  30. echo "hello!!!!!";
  31.  
  32. //execute query
  33. $retval = mysqli_query($link, $sql);
  34.  
  35.  
  36. //check success
  37. if(!$retval){
  38. die('Failure:' . mysql_error());
  39. echo "<script>console.log("failure")</script>";
  40. }
  41. else{
  42. echo "<script>console.log("failure")</script>";
  43. }
  44.  
  45.  
  46. }
  47.  
  48. function template($id, $fName, $lName, $email, $phone){
  49. //connect to database
  50. $link = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass);
  51.  
  52. //define sql code
  53. $sql = "";
  54.  
  55. //execute query
  56. $retval = mysqli_query($link, $sql);
  57.  
  58.  
  59. //check success
  60. if(!$retval){
  61. die('Failure:' . mysql_error());
  62. print("failure");
  63. }
  64. else{
  65. print("SUCCESS!");
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement