Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. <?php
  2. interface post_data {
  3.         function clean_data($username, $password);
  4.         function add_data($username, $password);
  5.         }
  6.  
  7. abstract class sql_server {
  8.         public $cnx;
  9.         public function __construct() {
  10.                 $this -> cnx = mysql_connect("localhost", "root", "password");
  11.                 mysql_select_db("register", $this -> cnx);
  12.                 }
  13.         }
  14.  
  15. class post_data_class extends sql_server implements post_data {
  16.         private $username;
  17.         private $password;
  18.  
  19.         public function __construct() {
  20.                 parent::__construct();
  21.                 $this -> username = $_POST["username"];
  22.                 $this -> password = $_POST["password"];
  23.  
  24.                  $this -> clean_data($this -> username, $this -> password);
  25.         }
  26.  
  27.         public function clean_data($username, $password) {
  28.                 $username = htmlentities($username);
  29.                 $password = htmlentities($password);
  30.  
  31.                 $username = mysql_real_escape_string($username);
  32.                 $password = mysql_real_escape_string($password);
  33.  
  34.                 $this -> username = $username;
  35.                 $this -> password = $password;
  36.  
  37.                 $this -> add_data($this -> username, $this -> password);
  38.         }
  39.  
  40.         public function add_data($username, $password) {
  41.                 $username = $this -> username;
  42.                 $password = $this -> password;
  43.  
  44.                 $query = "INSERT INTO
  45.                        `Users` (Username, Password)
  46.                        VALUES ('" . $username . "', '" . $password . "')";
  47.                 $query = mysql_query($query);
  48.         }
  49. }
  50.  
  51. $start = new post_data_class();
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement