Member Avatar for sundeep.gurroby

Hi guys, always a big thanks for your input. Really appreciate as always.

Ok my issue today is with the password_hash function which randomly generate a salt before encryption.

I am creating a user registration form...i need to protect the password before it is saved to the database when user registerss.

I have already visited the PHP manual here

But since i am a newbie in PHP i have no idea how to change my code to apply this function.

I am going to attach it here below. Please have a look and let me know how to proceed...Thanks.

<?php require_once('Connections/bankusers.php'); ?>

<?php

// table name
$tbl_name=temp_users_db;

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Email=$_POST['Email'];
$UserName=$_POST['UserName'];
$Password=$_POST['Password'];


// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, FirstName,LastName,Email,UserName,Password)VALUES('$confirm_code','$FirstName','$LastName','$Email','$UserName', '$Password')";
mysql_select_db($database_bankusers, $bankusers);
$result=mysql_query($sql);
Member Avatar for sundeep.gurroby

I think i solved my own problem lol...as usual.All i did was add this :

$unhashedPassword="Password";
$Password= password_hash($unhashedPassword, PASSWORD_DEFAULT);
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.