Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database
- {
- var $host="localhost";
- var $user="root";
- var $pass="";
- var $db="restaurant";
- public function connect()
- {
- $con=mysqli_connect($this->host,$this->user,$this->pass,$this->db);
- return $con;
- }
- public function saveRecords($tbName,$u,$p)
- {
- $conn=$this->connect();
- $sql = "insert into $tbName values('".$u."','".$p."')";
- $result = $conn->query($sql);
- }
- }
- ?>
- <?php
- $obj=new Database();
- extract($_POST);
- //Saved Records Inside Database
- if(isset($save))
- {
- //here admin is table name, $userName and $pass entered by html form
- $obj->saveRecords("abushan",$userName,$Pass);
- echo "Records Saved ";
- }
- ?>
- <form method="post">
- <table width="457" border="2" cellspacing="5" cellpadding="5">
- <tr>
- <th width="333" scope="row">Enter your user id </th>
- <td width="81"><input type="text" name="userName"/></td>
- </tr>
- <tr>
- <th scope="row">enter your password </th>
- <td><input type="text" name="Pass"/></td>
- </tr>
- <tr>
- <th colspan="2" scope="row">
- <input type="submit" value="save" name="save"/>
- </th>
- </tr>
- </table>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement