Create a PHP Login Script 2015(youtube).

serhiy-the-who

Nov 27th, 2016 01:43 PM

hi there, i have some problems with simple login php script.
actually i have problem like this - Notice: Only variables should be passed by reference in D:\X_AMPP\htdocs\www\register.php on line 15.

and my code on that lines (line 15 is - $stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT)); looks like -

 

//error_reporting(0);

require 'database.php';

$message = '';

if(!empty($_POST['email']) && !empty($_POST['password'])):

//Enter new user into DB!
$sql = "INSERT INTO users (email, password) VALUES (:email, :password)";
$stmt = $conn->prepare($sql);

$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));

if($stmt->execute()):
$message = 'Successfully crated new user';
else:
$message = 'Sorry there must have been an issue to create an account!';
endif;

endif;

?>

 

serhiy-the-who

Nov 27th, 2016 01:53 PM

alright my bad , already find the answer below :)

mark

Nov 27th, 2016 03:05 PM

To others finding same issue, the solution is simple to change:

$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));

to

$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
<p>$stmt->bindParam(':email', $email);
$stmt->bindParam(':password', $password);

mark

Jan 12th, 2017 08:27 AM

Just use PDO. PDO supports multiple drivers, including MySQL.
Drivers supported: http://php.net/manual/en/pdo.drivers.php

jake-lower

Jan 22nd, 2019 05:45 AM

Login scripts will always be really had to create from the different parts of the page in the You Tube channels. If problem from the references on the superiorpapers com website only be compact then register will be need only password and username.

anika-digital

Mar 1st, 2019 04:00 PM

I read that Post and got it fine and informative. Please share more like that...Great Article it it's really informative and innovative keep here: Quality web design & development services london with new updates. Its was really valuable. Thanks a lot.