Advertisement
Guest User

Untitled

a guest
Jul 10th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     $values = array(
  10.         "user" => $username,
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement