PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE users ( id int, username varchar(64), email varchar(64), password varchar(64), phone varchar(64) );
Copy Clear
Copy Format Clear
<?php $_POST = ['username' => 'abc', 'password' => 'qwerty']; $username = $_POST['username']; $password = md5($_POST['password']); $stmt = $pdo->prepare("SELECT id, username, email, phone FROM users WHERE username=? AND password=?"); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->execute([$username, $password]); if($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $user = array( 'id'=>$row['id'], 'username'=>$row['username'], 'password'=>$row['password'], 'phone'=>$row['phone'] ); }
Show:  
Copy Clear