encryptpass

This commit is contained in:
marian1010 2021-05-05 19:46:10 +02:00
parent a3ce8a7313
commit fbd5227780
2 changed files with 22 additions and 10 deletions

View File

@ -15,14 +15,22 @@
//Create a new user Manager. //Create a new user Manager.
public function createManager($id, $username, $email, $pass, $rol){ public function createManager($id, $username, $email, $pass, $rol){
$sql = sprintf( "INSERT INTO `users`( `id`, `username`, `email`, `password`, `rol`) $password = $this->encryptPass($pass);
$sql = sprintf( "INSERT INTO `users`( `id`, `username`, `email`, `passwd`, `rol`)
VALUES ( '%d', '%s', '%s', '%s', '%s')", VALUES ( '%d', '%s', '%s', '%s', '%s')",
$id, $username, $email, $pass, $rol); $id, $username, $email, $password, $rol);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul; return $resul;
} }
private function encryptPass($password){
//$password = hash('sha256', $password);
$password = password_hash($password, PASSWORD_DEFAULT);
return $password;
}
//Returns a query to get All the managers. //Returns a query to get All the managers.
public function allManagersData(){ public function allManagersData(){
@ -72,9 +80,10 @@
//Edit manager. //Edit manager.
public function editManager($id, $username, $email, $pass, $rol){ public function editManager($id, $username, $email, $pass, $rol){
$sql = sprintf( "UPDATE users SET email = '%s' , pass = '%s', $password = $this->encryptPass($pass);
$sql = sprintf( "UPDATE users SET email = '%s' , passwd = '%s',
WHERE users.id = '%d';", WHERE users.id = '%d';",
$email, $pass, $id); $email, $password, $id);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');

View File

@ -84,10 +84,10 @@
function addManager(){ function addManager(){
echo' <div class="column side"></div> echo' <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h2>Añadir promoción</h2> <h2>Añadir gerente</h2>
<form method="post" action="index.php?state=mp"> <form method="post" action="index.php?state=mp">
<fieldset id="promotion_form"> <fieldset id="manager_form">
<legend>Datos dela Promoción</legend> <legend>Datos del manager </legend>
<div> <div>
<input type="text" name="username" id="username" placeholder="Nombre" /> <input type="text" name="username" id="username" placeholder="Nombre" />
</div> </div>
@ -95,7 +95,10 @@
<input type="email" name="email" id="email" placeholder="email" /> <input type="email" name="email" id="email" placeholder="email" />
</div> </div>
<div> <div>
<input type="text" name="password" id="pass" placeholder="pass" /> <input type="text" name="pass" id="pass" placeholder="password" />
</div>
<div>
<input type="text" name="pass2" id="pass2" placeholder="confirm password" />
</div> </div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
@ -111,7 +114,7 @@
function deleteManager() { function deleteManager() {
echo'<div class="column side"></div> echo'<div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h2>Editar Promoción</h2> <h2>Borrar gerente</h2>
<form method="post" action="index.php?state=mp"> <form method="post" action="index.php?state=mp">
<div class="row"> <div class="row">
<fieldset id="promotion_form"> <fieldset id="promotion_form">
@ -136,7 +139,7 @@
function editManager() { function editManager() {
echo'<div class="column side"></div> echo'<div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h2>Editar promoción</h2> <h2>Editar gerente</h2>
<form method="post" action="index.php?state=mp"> <form method="post" action="index.php?state=mp">
<div class="row"> <div class="row">
<fieldset id="promotion_form"> <fieldset id="promotion_form">