Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <head>
  2. <?php
  3. $db_host = 'localhost'; // Server Name
  4. $db_user = 'root'; // Username
  5. $db_pass = ''; // Password
  6. $db_name = 'contacts'; // Database Name
  7.  
  8. $conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
  9. if (!$conn) {
  10. die ('Failed to connect to MySQL: ' . mysqli_connect_error());
  11. }
  12. ?>
  13. </head>
  14.  
  15. <body>
  16. <?php
  17. $Users_First_Name=filter_var($_POST['UsersFirstname']);
  18. $Users_Second_Name=filter_var($_POST['UsersSurname']);
  19. $Users_Gender=filter_var($_POST['gender']);
  20. $Forename=filter_var($_POST['firstname']);
  21. $Surname=filter_var($_POST['surname']);
  22. $Mobile=filter_var($_POST['phonenumber']);
  23. $Home_Phone=filter_var($_POST['homephonenumber']);
  24. $EMail=filter_var($_POST['email']);
  25. $address=filter_var($_POST['Home_Address']);
  26. $Group=filter_var($_POST['Groupe']);
  27.  
  28.  
  29. $query_string = "INSERT INTO contact
  30. (Users_First_Name, Users_Second_Name, Users_Gender, Forename,
  31. Surname, Mobile, Home_Phone, EMail, Home_Address, Groupe)
  32. VALUES
  33. ('". $Users_First_Name . "',
  34. '" . $Users_Second_Name . "',
  35. '" . $Users_Gender . "',
  36. '" . $Forename . "',
  37. '" . $Surname . "',
  38. '" . $Mobile . "',
  39. '" . $Home_Phone . "',
  40. '" . $EMail . "',
  41. '" . $address . "',
  42. '" . $Group . "',);";
  43.  
  44. if(mysqli_query($conn, $query_string)){
  45. echo "Records inserted successfully.";
  46. } else{
  47. echo "ERROR: Could not able to execute $query_string. " . mysqli_error($conn);
  48. }
  49.  
  50. if (!$query) {
  51. die ('SQL Error: ' . mysqli_error($conn));
  52. }
  53. ?>
  54. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement