Guest User

Untitled

a guest
Nov 4th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_connect(): (HY000/1045):
  2. Access denied for user 'freeload_retain'@'vps28004.inmotionhosting.com'
  3. (using password: NO) in /home/freeloadboard/public_html/insert.php on
  4. line 7
  5. [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_select_db() expects
  6. parameter 1
  7. to be mysqli, boolean given in /home/freeloadboard/public_html/insert.php
  8. on line 21
  9. [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_query() expects parameter
  10. 1 to be mysqli, boolean given in
  11. /home/freeloadboard/public_html/insert.php on line 45
  12.  
  13. <?php
  14. ini_set('display_errors', 1);
  15. ini_set('display_startup_errors', 1);
  16. error_reporting(E_ALL);
  17.  
  18. $con = mysqli_connect('##.##.###.##','freeload_retain','');
  19.  
  20. if(!$con)
  21. {
  22. echo "Not Connected to Server. ";
  23. }
  24. if(!mysqli_select_db($con, 'freeload_retain'))
  25. {
  26. echo "Database Not Selected. ";
  27. }
  28.  
  29. $Companyname = $_POST['companyname'];
  30. $Username = $_POST['username'];
  31. $Password = $_POST['password'];
  32. $Email = $_POST['email'];
  33.  
  34. $sql = "INSERT INTO clients (companyname, username, password, email)
  35. VALUES ('$Companyname', '$Username', '$Password', '$Email')";
  36.  
  37. if(!mysqli_query($con, $sql))
  38. {
  39. echo "Not Inserted. ";
  40. }
  41. else
  42. {
  43. echo "Inserted. ";
  44. }
  45. ?>
  46.  
  47. // ... Set your database connection variables
  48.  
  49. /*
  50. * Create the database connection, notice the
  51. * usage of mysqli instead of mysql
  52. */
  53. $connect = new mysqli($host, $user, $password, $database);
  54.  
  55. /*
  56. * The query, notice the usage of a question mark
  57. * on the place of the variables to be inserted
  58. */
  59. $sql = "INSERT INTO client (cname, tname, pname, ename) VALUES (?, ?, ?, ?)";
  60.  
  61. // Prepare the query using $connect->prepare()
  62. $stmt = $connect->prepare($sql);
  63.  
  64. // Check if the query was prepared
  65. if(!$stmt) {
  66. // ... Handle your error
  67. }
  68.  
  69. // Get $_POST variables
  70. $companyname = $_POST['companyname'];
  71. $username = $_POST['username'];
  72. $password = $_POST['password'];
  73. $email = $_POST['email'];
  74.  
  75. if(!$stmt->bind_param('ssss', $companyname, $username, $password, $email)) {
  76. // ... Handle your error
  77. }
  78.  
  79. if(!$stmt->execute()) {
  80. // ... Handle your error
  81. } else {
  82. echo 'Record inserted.';
  83. }
  84.  
  85. function hashPassword($password) {
  86. return password_hash($password, PASSWORD_DEFAULT);
  87. }
  88.  
  89. function verifyPassword($password, $hash) {
  90. return password_verify($password, $hash);
  91. }
Add Comment
Please, Sign In to add comment