Guest User

Untitled

a guest
Dec 1st, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $dbuser = "root";
  4. $dbpassword = "";
  5. $dbname = "wwm";
  6.  
  7. // Creates the connection and check if it sucessfully connected.
  8. try
  9. {
  10. $conn = new PDO("mysql:host=$host;dbname=$dbname", $dbuser, $dbpassword);
  11.  
  12. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  13. echo 'Connected to Database';
  14. }
  15. catch(PDOException $e)
  16. {
  17. echo $e->getMessage();
  18. }
  19. ?>
  20.  
  21. <?php
  22. include 'connect.php';
  23.  
  24. //So this code will run if user did submit the form:
  25. if (!empty($_POST))
  26. {
  27. $statement = $conn->prepare("INSERT INTO users(first_name, sur_name, email, password, role, region, survey) VALUES (:fname, :lname, :email, :password', :role, :region, :survey)");
  28.  
  29. $statement->bindParam(':fname', $_POST['fname']);
  30. $statement->bindParam(':lname', $_POST['lname']);
  31. $statement->bindParam(':email', $_POST['email']);
  32.  
  33. //do i use mb5 for password, or is there another way to increase password security?
  34. $statement->bindParam(':password', md5($_POST['password']));
  35. $statement->bindParam(':role', $_POST['role']);
  36. $statement->bindParam(':region', $_POST['region']);
  37. $statement->bindParam(':survey', $_POST['survey']);
  38. $statement->execute();
  39. }
  40. ?>
  41.  
  42. Here are one of the errors i keep getting:
Add Comment
Please, Sign In to add comment