Skip to content

update without story 4#2

Open
marko95stojanovic wants to merge 2 commits intomasterfrom
solution
Open

update without story 4#2
marko95stojanovic wants to merge 2 commits intomasterfrom
solution

Conversation

@marko95stojanovic
Copy link

// Story 0: request to find all username
/*
$stmt = ...
$stmt->execute();
$users = $stmt->fetchAll();
*/

CREATE TABLE user(
id INT not null PRIMARY KEY,
name VARCHAR(255) UNIQUE,
password VARCHAR(255),
date_time_inscription DATETIME,
date_time_last_connexion DATETIME
);

$e->getMessage() ) ); die(); } $dbh = new PDO($dsn, $userofdb, $passwordofdb); ?> = 4) { if(isset ($_POST["password"])){ $pattern = '/^(?=.*[!@#$%^&*-])(?=.*[0-9])(?=.*[A-Z]).{8,20}$/ '; if (preg_match($pattern, $password)) { $user = $dbh->prepare('SELECT * FROM user WHERE email = :email'); $user->execute(['email' => $email]); $useer = $user->fetch(); if (empty($user)){ $options = [ 'cost' => 12, ]; $passwordhash = password_hash($password, PASSWORD_BCRYPT, $options); $insert = $dbh->prepare('INSERT INTO user (email, name, password) VALUES (:email, :name, :password)'); $redirect = $insert->execute(array( 'email' => $email, 'name' => $name, 'password' => $password )); if($redirect){ header("Location: login.php"); } }else{ echo "Votre compte existe."; } } ?> prepare('SELECT * FROM user WHERE email = :email and password = :password'); $query->execute(['email' => $email, 'password' => $password]); $query = $query->fetch(); $newquery=$dbh->prepare('UPDATE user SET name=:newname WHERE id=:id'); $newquery->execute(['newname' => $newname, 'id' => $query[0]]); } ?> prepare('delete from user WHERE email = :email and password = :password'); $query->execute(['email' => $email, 'password' => $password]); $query = $query->fetch(); } ?> <title>Document</title>
update
<div>
    <button class="button_valider" type="submit">
        delete</button>
    </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants