Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3. $username = $_POST['usernameinput'];
  4. $password = $_POST['passwordinput'];
  5.  
  6. $servername = "localhost";
  7. $username = "USERNAMECENSOR";
  8. $password = "PASSWORDCENSOR";
  9. $dbname = "database";
  10.  
  11. try {
  12. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  13. // set the PDO error mode to exception
  14. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  15. $sql = "INSERT INTO accounts (username, password)
  16. VALUES ('$username', '$password')";
  17. // use exec() because no results are returned
  18. $conn->exec($sql);
  19. echo "Success";
  20. }
  21. catch(PDOException $e)
  22. {
  23. echo $sql . "<br>" . $e->getMessage();
  24. }
  25. $conn = null;
  26. }
  27. ?>
  28.  
  29. <form method="POST" action="">
  30. <input type="text" name="usernameinput"><br>
  31. <input type="password" name="passwordinput"><br>
  32. <input type="submit" class="button" value="Sign in">
  33. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement