Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. class Database
  3. {
  4. var $host="localhost";
  5. var $user="root";
  6. var $pass="";
  7. var $db="restaurant";
  8. public function connect()
  9. {
  10. $con=mysqli_connect($this->host,$this->user,$this->pass,$this->db);
  11. return $con;
  12. }
  13. public function saveRecords($tbName,$u,$p)
  14. {
  15. $conn=$this->connect();
  16. $sql = "insert into $tbName values('".$u."','".$p."')";
  17. $result = $conn->query($sql);
  18.  
  19. }
  20.  
  21. }
  22. ?>
  23.  
  24.  
  25. <?php
  26. $obj=new Database();
  27. extract($_POST);
  28. //Saved Records Inside Database
  29. if(isset($save))
  30. {
  31. //here admin is table name, $userName and $pass entered by html form
  32. $obj->saveRecords("abushan",$userName,$Pass);
  33. echo "Records Saved ";
  34. }
  35. ?>
  36.  
  37. <form method="post">
  38. <table width="457" border="2" cellspacing="5" cellpadding="5">
  39. <tr>
  40. <th width="333" scope="row">Enter your user id </th>
  41. <td width="81"><input type="text" name="userName"/></td>
  42. </tr>
  43. <tr>
  44. <th scope="row">enter your password </th>
  45. <td><input type="text" name="Pass"/></td>
  46. </tr>
  47.  
  48. <tr>
  49. <th colspan="2" scope="row">
  50. <input type="submit" value="save" name="save"/>
  51. </th>
  52. </tr>
  53. </table>
  54.  
  55. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement