Location: PHPKode > projects > Classifieds > classifieds/classes/Register.php
<?php



session_start();

include("../Db.php");

include("../URLs.php");



Class Register {   

    

    protected $firstName;

    protected $lastName;

    protected $email;

    protected $birthday;

    protected $password;

    protected $userID;

    

    function __construct($firstName, $lastName, $email, $birthday, $password) {

        include("Sanitize.php");  

        $this->firstName = Sanitize::clean($firstName);

        $this->lastName = Sanitize::clean($lastName);

        $this->email = strtolower(Sanitize::clean($email));

        $this->birthday = Sanitize::clean($birthday);

        $this->password = Sanitize::clean($password); 

        

        include("Validator.php");

        

        include("CommonFunctions.php");

                

        if(CommonFunctions::checkEmailExists($this->email)) { echo 'Email already exists.'; exit(); } 

        

        if(!Validator::Email($this->email)) { echo 'Not a valid email address'; exit(); } 

        

        $this->password = CommonFunctions::hashPass($this->password);

        

        $this->signUp();    

    } 



    protected function signUp() {     

        if(mysql_query("INSERT INTO Users SET firstName='$this->firstName', lastName='$this->lastName', email='$this->email', birthday='$this->birthday', password='$this->password', dateSignUp=CURDATE(), isActive='0'"))

        {

            $this->sendConfirmation();            

        }

    }

    

    protected function sendConfirmation() {

        $confirmLink = DOMAIN ."confirmRegister.php?user=$this->email";

        $this->message = "

        

                Thank you for registering. Please confirm your email address by clicking the link below.

                

                $confirmLink                

        

        ";        

        mail($this->email, 'Confirm your registration.', $this->message);       

        header("Location: " . DOMAIN . 'checkYourEmail.php');

    }    

        

}



$register = new Register($_POST['firstName'], $_POST['lastName'], $_POST['email'], $_POST['birthday'], $_POST['password']);



?>
Return current item: Classifieds