Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('connect.php');
- class Register {
- public $username;
- public $password;
- public $repeatpass;
- public $email;
- public $firstname;
- public $lastname;
- public $date;
- public $registerchecks;
- function __construct() {
- $this->username = $_POST['username'];
- $this->password = $_POST['password'];
- $this->repeatpass = $_POST['repeatpass'];
- $this->email = $_POST['email'];
- $this->firstname = $_POST['firstname'];
- $this->lastname = $_POST['lastname'];
- $this->date = date('Y-m-d');
- }
- public function RegisterUser() {
- $username_check = "SELECT username FROM accounts WHERE username='$this->username'";
- $run_username_check = mysql_query($username_check);
- $username_check_num_rows = mysql_num_rows($run_username_check);
- $email_check = "SELECT email FROM accounts WHERE email='$this->email'";
- $run_email_check = mysql_query($email_check);
- $email_check_num_rows = mysql_num_rows($run_email_check);
- if (strlen($this->username)>25) {
- die ("Username too Long, must be less than 26 characters!");
- } else if (!preg_match('#[0-9]#', $this->password)) {
- die ("Password must have at least one number!");
- } else if ($username_check_num_rows>=1) {
- die ("Username already taken!");
- } else if ($email_check_num_rows>=1) {
- die ("Email already in use!");
- } else if (strlen($this->password)<6) {
- die ("Password is too short, must be at least 6 characters!");
- } else if ($this->password!=$this->repeatpass) {
- die ("Passwords did not match!");
- } else {
- $md5pass = md5($this->password);
- $insert = "INSERT INTO accounts VALUES('','$this->username','$md5pass','$this->email','$this->date','$this->firstname','$this->lastname','')";
- $run_insert = mysql_query($insert);
- if (!$run_insert) {
- die ("Something went wrong, please try again :-(");
- } else {
- echo "Registered Successfully!";
- }
- }
- }
- }
- if(isset($_POST['submit'])) {
- $register = new Register();
- $register->RegisterUser();
- }
- ?>
Add Comment
Please, Sign In to add comment