Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "";
  4. $password = "";
  5. try{
  6. $conn = new PDO("mysql:host=$servername;dbname=iltcis_People_email_address", $username, $password);
  7. // set the PDO error mode to exception
  8. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9. echo "Connected successfully</br>";
  10. $firstname = $_REQUEST['firstName'];
  11. $email = $_REQUEST['email'];
  12. $gender = $_REQUEST['gender'];
  13.  
  14. $age =$_REQUEST['age'];
  15. $lastName = $_REQUEST['lastName'];
  16. $comments = $_REQUEST['comments'];
  17. $id=$_REQUEST['id'];
  18. echo "User: $firstName ($gender), with following email: $email, $age y.o., wrote $comments";
  19.  
  20. $sql = "INSERT INTO People (id,age, comments, email, firstName, gender,lastName)";
  21.  
  22. VALUES ('$id', '$name', '$gender','$email','$age','$comments', '$lastName');
  23.  
  24. //use exec() because no results are returned
  25.  
  26. $conn->exec($sql);
  27. }
  28. catch(PDOException $e)
  29. {
  30. echo "Connection failed: " . $e->getMessage();
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement