Advertisement
Guest User

Untitled

a guest
Jul 10th, 2013
85
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.     $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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement