Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <form name="add" action="add.php" method="post">
  9. <input type="text" name="fname"><br/>
  10. <input type="text" name="sname"><br/>
  11. <input type="text" name="email"><br/>
  12. <input type="text" name="cat"><br/>
  13. <input type="Submit" value="Add Record"/>
  14. </form>
  15.  
  16. </body>
  17. </html>
  18.  
  19.  
  20.  
  21.  
  22. <?php
  23. $servername = "localhost";
  24. $username = "root";
  25. $password = "";
  26. $dbname = "contactsDB";
  27.  
  28. $fname = $_POST['fname'];
  29. $sname = $_POST['sname'];
  30. $email = $_POST['email'];
  31. $cat = $_POST['cat'];
  32.  
  33. // Create connection
  34. $conn = new mysqli($servername, $username, $password, $dbname);
  35. // Check connection
  36. if ($conn->connect_error) {
  37. die("Connection failed: " . $conn->connect_error);
  38. }
  39.  
  40. $sql = "Insert into contactsTbl(fname, sname, email, cat) values('$fname', '$sname', '$email', '$cat')";
  41. echo $sql;
  42. $result = $conn->query($sql);
  43.  
  44. $conn->close();
  45. ?>
  46. <a href="all.php">All Records</a>
  47. <a href="work.php">Work Records</a>
  48. <a href="personal.php">Personal Records</a>
  49. <a href="add.html">Add New</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement