Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface post_data {
- function clean_data($username, $password);
- function add_data($username, $password);
- }
- abstract class sql_server {
- public $cnx;
- public function __construct() {
- $this -> cnx = mysql_connect("localhost", "root", "password");
- mysql_select_db("register", $this -> cnx);
- }
- }
- class post_data_class extends sql_server implements post_data {
- private $username;
- private $password;
- public function __construct() {
- parent::__construct();
- $this -> username = $_POST["username"];
- $this -> password = $_POST["password"];
- $this -> clean_data($this -> username, $this -> password);
- }
- public function clean_data($username, $password) {
- $username = htmlentities($username);
- $password = htmlentities($password);
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- $this -> username = $username;
- $this -> password = $password;
- $this -> add_data($this -> username, $this -> password);
- }
- public function add_data($username, $password) {
- $username = $this -> username;
- $password = $this -> password;
- $query = "INSERT INTO
- `Users` (Username, Password)
- VALUES ('" . $username . "', '" . $password . "')";
- $query = mysql_query($query);
- }
- }
- $start = new post_data_class();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement