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