Guest User

Untitled

a guest
Oct 24th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "test";
  7.  
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9.  
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13. else{
  14. $no=$_POST['No'];
  15. $name=$_POST['nama'];
  16. $TL=$_POST['TL'];
  17. $TGLLH=$_POST['date'];
  18. $HB=$_POST['HB'];
  19.  
  20. $sql = "INSERT INTO myfamily (`No`,`nama`, `t4lahir`, `tgl_lahir`, `hobby`) VALUES ('$no','$name','$TL','$TGLLH','$HB')";
  21.  
  22. if (mysqli_query($conn, $sql)) {
  23. echo "<script>alert('Data berhasil di tambahkan!');history.go(-1);</script>";
  24. } else
  25. {
  26. echo "<script>alert('Hello How are you?');history.go(-1);</script>";
  27. }
  28. mysqli_close($conn);
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment