4. Data Insert

  1. Method
    obviously have to put this code in fresh.php. where have your database connect.

    public function Insert($table,$id,$name,$email,$phone,$address){
           $query = mysqli_query($this->connect, "INSERT INTO $table SET id='$id', name='$name', email='$email', phone='$phone', address='$address'");
               return true;
               return false;

  2. create insert.php file

if (isset($_REQUEST['submit'])) {
    if ($obj->Insert("members", $id, $name, $email, $phone, $address)) {
        header('location:tabulize_data.php'); // Where have your data show
    } else {
        $err_msg = "No Data Insert in Your table";

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Show Database</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

        <div style="width: 700px; margin: 0 auto">
            <!-- ternary operators -->
            echo (isset($err_msg)) ? $err_msg : "";
                <table class="table table-bordered table-hover" style="text-align: center;">  
                        <td colspan="2">Insert Your Information</td>
                        <td><input name="id" class="form-control" type="text" ></td>
                        <td><input name="name" class="form-control" type="text" placeholder="Enter Your Name" required="required"></td>
                        <td><input name="email" class="form-control" type="text" placeholder="Enter Your valid Email" required="required"></td>
                        <td><input name="phone" class="form-control" type="text" placeholder="Enter Your Number" required="required"></td>
                        <td><textarea name="address" class="form-control"></textarea></td>
                        <td colspan="2" align="center"><input type="submit" value="Save" name="submit" class="btn btn-primary"></td>

Insert form look like following screenshot:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s