SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | ||
3 | if(isset($_POST['formsub'])) { | |
4 | $username = $_POST['user']; | |
5 | $password = $_POST['pass']; | |
6 | ||
7 | $pdo = new PDO("mysql:host=localhost;dbname=database", 'username', 'password'); | |
8 | $query = $pdo->prepare("INSERT INTO users (user,pass) VALUES (:user,:pass)"); | |
9 | - | $query->bindValue(":user", $username, PDO::PARAM_STR); |
9 | + | $values = array( |
10 | - | $query->bindValue(":pass", $password, PDO::PARAM_STR); |
10 | + | "user" => $username, |
11 | - | $query->execute(); |
11 | + | "pass" => $password |
12 | ); | |
13 | $query->execute($values); | |
14 | } | |
15 | ||
16 | ?> | |
17 | ||
18 | <form action="index.php" method="post"> | |
19 | username: <input type="text" name="user"><br> | |
20 | password: <input type="password" name="pass"><br> | |
21 | <input type="hidden" name="formsub" value="1"> | |
22 | <input type="submit"> | |
23 | </form> |