daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Sep 3rd, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PHP PDO connection failure
  2. <?php
  3.  
  4. include("class.php");
  5.  
  6. $dbhost     = "localhost";
  7. $dbname     = "db";
  8. $dbuser     = "user";
  9. $dbpass     = "pass";
  10.  
  11. $conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
  12.  
  13. $username = $_POST['username'];
  14. $password = $_POST['password'];
  15. $email = strtolower($_POST['email']);
  16. $firstName = ucwords(strtolower($_POST['firstName']));
  17. $lastName = ucwords(strtolower($_POST['lastName']));
  18. $date = date("Y-m-d");
  19. $hash = Secure::Encrypt($username, $password);
  20.  
  21. $sql = "INSERT INTO users (username,password,email,firstName,lastName,createDate) VALUES (:username,:password,:email,:firstName,:lastName,:date)";
  22. $q = $conn->prepare($sql);
  23. $q->execute(array(
  24. ':username'=>$username,
  25. ':password'=>$hash,
  26. ':email'=>$email,
  27. ':firstName'=>$firstName,
  28. ':lastName'=>$lastName,
  29. ':date'=>$date));
  30.  
  31. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top