Member Avatar for roxanne.martos

Hi i am reworking on my password security on the register page so far it is okay apart from the fact that im getting this error:

Fatal error: Call to a member function create() on a non-object

` $bcrypt = new Bcrypt;

try {
    $email1->create(array(
       ` 'username' => Input::get('username'),`
        'password1' => $bcrypt->hash(Input::get('password')),
        'firstname' => Input::get('name'),
        'surname' => Input::get('surname'),
        'pnumber' => Input::get('pnumber'),
        'email1' => Input::get('email'),
        'ipaddress' => Input::get('ipaddress'),
        'signup_date' => date('Y-m-d H:i:s'),
        'group' => 1
    ));`

the error is on the line

'username' => Input::get('username'),

does anyone have an idea of what it could be?

Recommended Answers

All 3 Replies

Fatal error: Call to a member function create() on a non-object

That means the problem is with: $email1->create()

There should be a line $email1 = new SomeClass(), is it missing?

Member Avatar for roxanne.martos

yes i dont actually have one, is this class a separate document?

`<?php

error_reporting(E_ALL);
include_once("conninfo2.php"); 
include_once('classes/bcrypt.php'); 

if(isset($_POST['username'])) {
   $firstname = strip_tags($_POST['firstname']);
   $surname = strip_tags($_POST['surname']);
   $pnumber = strip_tags($_POST['pnumber']);
   $username = strip_tags($_POST['username']);
   $email1 = strip_tags($_POST['email1']);
   $email2 = strip_tags($_POST['email2']);
   $password1 = $_POST['password1'];
   $password2 = $_POST['password2'];


   //code below will make sure all fields are filled in
   if(trim($firstname) == "" || trim($surname) == "" || trim($pnumber) == "" || trim($username) == "username" || trim($email1) == "" || trim($email2) == "" ||trim($password1) == "" || trim($password2) == "") {
   echo "Error, all fileds need to be filled in";
   $db = null;
   exit();
   }


   //code below checks that the emails entered both match one another
   if($email1 != $email2) {
   echo "Emails do not match, please try again";
   $db = null;
   exit();
   }

   //code below matches the passwords entered
   else if($password1 != $password2) {
   echo "Passwords do not match please try again";
   exit();
   }

   if(!filter_var($email1, FILTER_VALIDATE_EMAIL)) {
   echo "Your email is invalid, please try again";
   $db = null;
   exit();
   }

   //checks if the email exists within the database
   $stmt = $db->prepare("SELECT email FROM login WHERE email=:email1 LIMIT 1");
   $stmt->bindValue(':email1',$email1, PDO::PARAM_STR);
   try{
   $stmt->execute();
   $count = $stmt->rowCount();
   }
   catch(PDOException $e) {
   echo $e->getMessage();
   $db = null;
   exit();
   }

   //checks if the username exists
   $usernameSQL = $db->prepare("SELECT username FROM login WHERE username=:username LIMIT 1");
   $usernameSQL->bindValue(':username',$username,PDO::PARAM_STR);
   try{
   $usernameSQL->execute();
   $usernameCount = $usernameSQL->rowCount();
   }
   catch(PDOExemption $e) {
   echo $e->getMessage();
   $db = null;
   exit();
   }

   //checks if the email is already within the database
   if($count > 0) {
   echo "This email already exists";
   $db = null;
   exit();
   }

   //checks the username
   if($usernameCount > 0) {
   echo "This username is unavailable please try another";
   $db = null;
   exit();
   }

   if($validation->passed()) {
    $user = new User;
    $bcrypt = new Bcrypt;


try {
    $email1->create(array(
        'username' => Input::get('username'),
        'password1' => $bcrypt->hash(Input::get('password')),
        'firstname' => Input::get('name'),
        'surname' => Input::get('surname'),
        'pnumber' => Input::get('pnumber'),
        'email1' => Input::get('email'),
        'ipaddress' => Input::get('ipaddress'),
        'signup_date' => date('Y-m-d H:i:s'),
        'group' => 1
    ));

//grab the last id used within the database
$lastId = $db->lastInsertId();
$stmt3 = $db->prepare("INSERT INTO activated (user, token) VALUES ('$lastId', :token)");
$stmt3->bindValue(':token',$token,PDO::PARAM_STR);
$stmt3->execute();

//email activation
$from = "From Auto Responder @ Mediaedit <admin@mediaedit.com>";
$subject = "IMPORTANT: Please activate your account";
$link = 'http://mediaed.it/roxanne/activate.php?user='.$lastId.'&token='.$token.'';

//email body
$message = "
Thanks for register with Mediaedit, before your able to use our services you will need to verify your email so that we know your human

$link
";

//headers
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= "Content-type: textrn";
$headers .= "From: Mediaedit";

//send email now
mail($email1, $subject, $message, $headers, '-f noreply@mediated.it');
$db->commit();
echo "Thanks for registering, before you can us our services you need to activate your account an email has been sent which you will recieve shortly";
$db = null;
exit();
}

catch(PDOException $e){
$db->rollBack();
echo $e->getMessage();
$db = null;
exit();
}
}
?>`
Member Avatar for roxanne.martos

i have this
$email = new User;

however i got
Fatal error: Class 'User' not found in

im fairly new to this, can the new User be changed to something else?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.