Advertisement
Guest User

example

a guest
Sep 13th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.     class database
  3.     {
  4.         function __construct()
  5.         {
  6.             $this->dBusername = 'xxx';
  7.             $this->dBpassword = 'xxx';
  8.             $this->dBhost = 'localhost';
  9.             $this->dBdatabase = 'xx';
  10.             $this->dBcharset = 'utf8';
  11.         }
  12.  
  13.         function register_account($username, $password, $email, $activation_id)
  14.         {
  15.             $mysqli = new mysqli($this->dBhost, $this->dBusername, $this->dBpassword, $this->dBdatabase);
  16.            
  17.             if(mysqli_connect_error())
  18.             {
  19.                 return false;
  20.                 exit;
  21.             }
  22.  
  23.             $sql = "INSERT INTO users (username, password, email, activation_id) VALUES (?, ?, ?, ?)";
  24.             $stmt = $mysqli->prepare($sql);
  25.             $stmt->bind_param("s, s, s, s", $username, $password, $email, $activation_id);
  26.             $stmt->execute();
  27.             $stmt->close();
  28.             $mysqli->close();
  29.         }
  30.  
  31.         function authenticate_account($username, $password)
  32.         {
  33.             // And so on
  34.         }
  35.     }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement