SHARE
TWEET

Untitled

a guest May 31st, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "cursWD";
  7.  
  8. $name = $_POST["name"];
  9. $email = $_POST["email"];
  10. $spec = $_POST["spec"];
  11.  
  12.  
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14.  
  15. // Check connection
  16. if ($conn->connect_error) {
  17.     die("Connection failed: " . $conn->connect_error);
  18. }
  19.  
  20. $sql = "INSERT INTO Students (id, name, email, spec) VALUES ('','$name','$email','$spec')";
  21.  
  22. if ($conn->query($sql) === TRUE) {
  23.     echo "New record created successfully";
  24. } else {
  25.     echo "Error: " . $sql . "<br>" . $conn->error;
  26. }
  27.  
  28. $conn->close();
  29.  
  30. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top