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.
WF-Website/public/script/user.php

60 lines
1.5 KiB

<?php
class User{
public string $id;
public string $username;
public string $passwd;
public string $hidenPasswd;
public string $img;
public string $email;
function __construct(string $id, string $pseudo, string $password, string $image, string $mail) {
$this->id = $id;
$this->username = $pseudo;
$this->passwd = $password;
$this->hidenPasswd = hidenPassWd($password);
$this->img = $image;
$this->email = $mail;
}
public function updateUsername(string $newUsername){
if(isset($newUsername)){
$this->username = $newUsername;
}
}
public function updateEmail(string $newEmail) {
if(isset($newEmail)){
$this->email = $newEmail;
}
}
public function modifyImage(string $image){
if(isset($image)){
$u->img = $image;
}
}
}
include("Connection.php");
$dsn = "pgsql:host=londres;dbname=";
$username = "";
$password = "";
$con = new Connection($dsn,$username,$password);
$query = 'SELECT * FROM Users WHERE id_user=:idUser';
$con->executeQuery($query, array(':idUser'=>array('U001', PDO::PARAM_STR)));
$result = $con->getResults();
$u = new User($result[0]['id_user'],$result[0]['username'], $result[0]['pssword'], '../../images/imageProfil.png', $result[0]['email']); /*Test*/
function hidenPassWd(string $passwd){
if(strlen($passwd) >= 16) return str_repeat('*', 16);
return str_repeat('*', strlen($passwd));
}
?>