Projecte M07, botiga en php.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
1.1 KiB

<?php
include_once('parameters.php');
$username = $_POST['username'];
$userpass = password_hash($_POST['userpass'], PASSWORD_DEFAULT);
//========================================================================================================================================================
// Guardem les dades de lusuari a la bdd
try {
$sql = $con->prepare("INSERT INTO bp_users(bp_user_name, bp_user_pass, bp_user_addDate) VALUES(?, ?, ?);");
$sql->bind_param('sss', $username, $userpass, date("Y-m-d"));
$rs = $sql->execute();
if($rs) {
$response['success'] = true;
} else {
$response['success'] = false;
throw new Exception("Hi ha hagut un error al insertar el registre");
}
// if($rs) {
// echo ("El registre ha estat satisfactori");
// } else {
// echo ("Hi ha hagut un error al insertar el registre");
// }
} catch( Exception $e ) {
$response['message'] = $e->getMessage();
}
echo json_encode($response);
?>