Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. if( !isset($_POST['First_Name']) ){
  9.  
  10. die("You did not enter a valid first name.");
  11. }
  12.  
  13. if( !isset($_POST['Last_Name']) ){
  14.  
  15. die("You did not set your last name properly.");
  16. }
  17.  
  18. if( !isset($_POST['Email']) ){
  19.  
  20. die("You did not set the email right.");
  21. }
  22.  
  23. $email = $_POST['Email'];
  24.  
  25. if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  26. echo("$email is a valid email address");
  27. } else {
  28. echo("$email is not a valid email address");
  29. }
  30.  
  31. //now connect
  32.  
  33. $servername = "80.82.112.181";
  34. $username = "15095173u2";
  35. $password = "15095173p2";
  36. $dbname = "15095173_music_db";
  37.  
  38. $conn = new mysqli($servername, $username, $password, $dbname);
  39. if ($conn->connect_error) {
  40. die("Connection failed: " . $conn->connect_error);
  41. }
  42.  
  43.  
  44.  
  45.  
  46. //sanatize everything
  47.  
  48. $first= $conn->real_escape_string($_POST['First_Name']);
  49. $last= $conn->real_escape_string($_POST['Last_Name']);
  50. $email= $conn->real_escape_string($_POST['Email']);
  51.  
  52.  
  53.  
  54. //now set up your query.. it should be an insert
  55. $sql = "INSERT INTO customers (First_name, Last_name, Email) VALUES('" . $first . "','" . $last . "','" . $email . "')" ;
  56. echo "Welcome to iSongs: " . $first . " " . $last . ", ";
  57.  
  58.  
  59.  
  60.  
  61. //run your query
  62. if( $result = $conn->query($sql) ){
  63. //successful query
  64. } else {
  65. die("query failed");
  66. }
  67.  
  68. //were done.
  69. die("Thanks for signing up!");
  70.  
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement