Jump to content

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION


R0xxy
Go to solution Solved by ginerjm,

Recommended Posts

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

class User 
	{
  	 private $_bcrypt;
	$this->_bcrypt = new Bcrypt;	
	if($this->_bcrypt->verify($password, $this->data()->password)){
	}

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();
   }
   
    $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();
   	}
   	}
   	?>

i keep getting Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.