Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "contactsDB";
  6.  
  7. $fname = $_POST['fname'];
  8. $sname = $_POST['sname'];
  9. $email = $_POST['email'];
  10. $cat = $_POST['cat'];
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14. // Check connection
  15. if ($conn->connect_error) {
  16. die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19. $sql = "Insert into contactsTbl(fname, sname, email, cat) values('$fname', '$sname', '$email', '$cat')";
  20. //echo $sql;
  21. $result = $conn->query($sql);
  22.  
  23. $conn->close();
  24. header("location:http://localhost:8080/contacts/all.php");
  25. die();
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement