Error: Undefined index: Password in C and error Strict standards: Only variables should be passed by Reference

Asked

Viewed 91 times

0

error referring to the same line of code :

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

Who Accumulate and record the information entered in the form with the following line

<input type="Password" placeholder="Password" name="Password">

Password Field is also correctly closed with "P" in Mysql.

Full block :

if(!empty ($_POST['Username']) && !empty($_POST['Password']));



$sql ="INSERT INTO users (Username,Password) values (:Username, :Password)";
$stmt= $conn->prepare ($sql);
$stmt->bindParam (':Username', $_POST['Username']);
$stmt->bindValue(':Password', password_hash($_POST ['Password'], PASSWORD_BCRYPT));

    if ($stmt-> execute()  ):
        die('success');
        else:  ................

Help please ?

  • about the password, edit and put the query. But the error is clear, no Password name bind replacement has been defined in it.

  • see also: http://answall.com/questions/88400/70

  • replace "param" with "value" solved the second error. In fact I don’t see what could be causing that error, I have lines of identity code that are working fine. the Password field is not only closed with pass instead of text, it has the hash . is the only difference..

  • Is that PDO or mysqli? PDO has :named, mysqli does not.

  • PDO. updated the code above

  • Separate the contents with something like this: $hash = password_hash($_POST ['Password'], PASSWORD_BCRYPT); and then $stmt->bindValue(':Password', $hash );

  • Didn’t work =\

Show 2 more comments

1 answer

1


$email =  $_POST['email'];
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);

$stmt->bindParam(':email', $email);
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password',$password);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.