Click here to Skip to main content
15,908,775 members
Home / Discussions / Web Development
   

Web Development

 
QuestionHow to Fill docing of a fieldset at HTML document? Pin
ICEFLOWER224-Feb-18 15:50
ICEFLOWER224-Feb-18 15:50 
AnswerRe: How to Fill docing of a fieldset at HTML document? Pin
W Balboos, GHB28-Feb-18 7:57
W Balboos, GHB28-Feb-18 7:57 
AnswerRe: How to Fill docing of a fieldset at HTML document? Pin
Christopher Charles8-May-18 1:02
Christopher Charles8-May-18 1:02 
Questioni want to create a website which shows import days Pin
Member 1369422524-Feb-18 1:26
Member 1369422524-Feb-18 1:26 
AnswerRe: i want to create a website which shows import days Pin
OriginalGriff24-Feb-18 1:27
mveOriginalGriff24-Feb-18 1:27 
AnswerRe: i want to create a website which shows import days Pin
David Mujica26-Feb-18 7:47
David Mujica26-Feb-18 7:47 
QuestionMy Project on office365 Pin
Ademola Ogunlana21-Feb-18 2:35
professionalAdemola Ogunlana21-Feb-18 2:35 
QuestionFatal error: Uncaught Error: Call to a member function prepare() on null Pin
Member 1368819820-Feb-18 17:59
Member 1368819820-Feb-18 17:59 
Hi I get an error as below
Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\crm_ppp\public_html\includes\user.php:24 Stack trace: #0 C:\xampp\htdocs\crm_ppp\public_html\includes\user.php(37): User->emailExists('david@jait.co.z...') #1 C:\xampp\htdocs\crm_ppp\public_html\includes\user.php(58): User->createUserAccount('David', 'david@jait.co.z...', 'TheITGuy001', 'Admin') #2 {main} thrown in C:\xampp\htdocs\crm_ppp\public_html\includes\user.php on line 24

code:
<?php

/*
*   User Class for account creation and login
*/

class User{

    private $con;
    private $user;

    function _construct()
    {
        include_once("../database/db.php");
        $db = new Database();
        $this->con = $db->connect();
    }

    //User already exists
    function emailExists($email){
        $pre_stmt = $this->con->prepare("SELECT id FROM user WHERE email= ?");
        $pre_stmt->bind_param("s", $email);
        $pre_stmt->execute() or die($this->con->error);
        $result = $pre_stmt->get_result();
        if($result->num_rows > 0){
            return 1;
        }else{
            return 0;
        }
    }

    function createUserAccount($username, $email, $password, $usertype){

        if($this->emailExists($email)){
            return "EMAIL_ALREADY_EXISTS";
        }else{
            $pass_hash = paswword_hash($password,PASSWORD_BCRYPT,["cost"=>8]);
            $date = date("Y-m-d");
            $notes = "";
            $pre_stmt = $this->con->prepare("INSERT INTO <code>user</code>( <code>username</code>, <code>email</code>, <code>password</code>, <code>usertype</code>, <code>register_date</code>, <code>last_login</code>, <code>notes</code>) VALUES (?,?,?,?,?,?,?)");
            $pre_stmt->bind_param('sssssss',$username,$email,$pass_hash,$usertype,$date,$date,$notes);
            $result = $pre_stmt->execute() or die($this->con->error);
            if($result){
                return $this->con->insert_id;
            }else{
                return "SOME_ERROR";
            }
        }

    }
    }

$user = new User();
$user->createUserAccount("David","david@jait.co.za","TheITGuy001","Admin"); 

?>

Anyone have any ideas
AnswerRe: Fatal error: Uncaught Error: Call to a member function prepare() on null Pin
Richard MacCutchan20-Feb-18 21:39
mveRichard MacCutchan20-Feb-18 21:39 
QuestionOPENID Connect Sharing Token. Pin
idreesbadshah19-Feb-18 2:28
idreesbadshah19-Feb-18 2:28 
QuestionGetting records from multiple tables Pin
Valecia_cho18-Feb-18 8:56
Valecia_cho18-Feb-18 8:56 
AnswerRe: Getting records from multiple tables Pin
W Balboos, GHB23-Feb-18 3:44
W Balboos, GHB23-Feb-18 3:44 
QuestionCreate a website to teach Pin
RV202012-Feb-18 23:56
RV202012-Feb-18 23:56 
AnswerRe: Create a website to teach Pin
Richard MacCutchan13-Feb-18 1:58
mveRichard MacCutchan13-Feb-18 1:58 
GeneralRe: Create a website to teach Pin
RV202013-Feb-18 2:07
RV202013-Feb-18 2:07 
GeneralRe: Create a website to teach Pin
RV202013-Feb-18 2:07
RV202013-Feb-18 2:07 
AnswerRe: Create a website to teach Pin
Kate Holloway18-Feb-18 0:14
Kate Holloway18-Feb-18 0:14 
QuestionURL rewriting with pure php and .htaccess Pin
partapsingh8-Feb-18 20:41
partapsingh8-Feb-18 20:41 
AnswerRe: URL rewriting with pure php and .htaccess Pin
luplup9-Feb-18 13:57
luplup9-Feb-18 13:57 
QuestionScroll Down!! Pin
User 98970747-Feb-18 9:38
User 98970747-Feb-18 9:38 
AnswerRe: Scroll Down!! Pin
Richard Deeming7-Feb-18 11:20
mveRichard Deeming7-Feb-18 11:20 
GeneralRe: Scroll Down!! Pin
User 98970748-Feb-18 0:26
User 98970748-Feb-18 0:26 
GeneralRe: Scroll Down!! Pin
Richard Deeming8-Feb-18 0:53
mveRichard Deeming8-Feb-18 0:53 
GeneralRe: Scroll Down!! Pin
User 98970748-Feb-18 1:04
User 98970748-Feb-18 1:04 
GeneralRe: Scroll Down!! Pin
Richard Deeming8-Feb-18 1:08
mveRichard Deeming8-Feb-18 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.