Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DBHandler {
- public $decryptionKey = "hi";
- public $dbhost;
- public $dbuser;
- public $dbpass;
- function DBHandler(){
- echo $this->decryptionKey;
- $this->decryptionKey = "PASSWORD";
- echo $this->decryptionKey;
- $this->dbhost = 'localhost:3306';
- $this->dbuser = 'root';
- $this->dbpass = 'password';
- }
- function insertStudent($id, $fName, $lName, $email, $phone){
- //connect to database
- echo $this->decryptionKey;
- echo "hello";
- $link = mysqli_connect('localhost:3306', 'root', 'password', "", 3306);
- echo "world";
- //define sql code
- $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);";
- echo "hello!!!!!";
- //execute query
- $retval = mysqli_query($link, $sql);
- //check success
- if(!$retval){
- die('Failure:' . mysql_error());
- echo "<script>console.log("failure")</script>";
- }
- else{
- echo "<script>console.log("failure")</script>";
- }
- }
- function template($id, $fName, $lName, $email, $phone){
- //connect to database
- $link = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass);
- //define sql code
- $sql = "";
- //execute query
- $retval = mysqli_query($link, $sql);
- //check success
- if(!$retval){
- die('Failure:' . mysql_error());
- print("failure");
- }
- else{
- print("SUCCESS!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement