tommy_spt

File php kedua

Feb 6th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /*db_config.php*/
  2.  
  3. <?php
  4. define("DB_HOST", "localhost");
  5. define("DB_USER", "root");
  6. define("DB_PASSWORD", "");
  7. define("DB_DATABASE", "mahasiswa");
  8. ?>
  9.  
  10.  
  11. /*creat_nama.php*/
  12. <?php
  13. $respon = array();
  14. if (isset($_GET['nama_mhs'])) {
  15. $nama_mhs = $_GET['nama_mhs'];
  16.  
  17. mysql_connect("localhost","root","") or die("gagal melakukan koneksi");
  18. mysql_select_db("mahasiswa") or die("Gagal memilih database");
  19. $sql = "INSERT INTO tbl_input(nama_mhs) VALUES ($nama_mhs)";
  20. $query = mysql_query($sql);
  21. mysql_close();
  22. }
  23. ?>
  24.  
  25.  
  26.  
  27. /*db_connect.php*/
  28. <?php
  29. class DB_CONNECT {
  30. function __construct() {
  31. $this->connect();
  32. }
  33.  
  34. function __destruct(){
  35. $this->close();
  36. }
  37.  
  38. function connect() {
  39. include '../Android_client/db_config.php';
  40. $con = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE ) or die (mysql_error());
  41. $db = mysql_select_db(DB_DATABASE) or die (mysql_error());
  42. return $con;
  43. }
  44. function close() {
  45. mysql_close();
  46. }
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment