How to store customer detail in database and how to show in specific page

First Create index.php and type below code.

<?php 
//mysqli connectivity
$connect= new mysqli("localhost","root","","dt50") or die("ERROR:could not connect to the database!!!!");
extract($_POST);

if(isset($submit))
{
 $query="insert into user values('$emp_id','$emp_name','$email','$phone','$company','$del_add','$pin_code','$country','$state','$city','$message')";
 if($connect->query($query))
 {
 header("Location: Thanks.html");
 }
 else
 {
 echo 'data not saved '.$connect->error;
 }
}

?>



<html>
    <head>
        <title>DT-50 EDM</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
        <link href='https://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
        <link href='custom.css' rel='stylesheet' type='text/css'>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://iamrohit.in/lab/js/location.js"></script>
        
    </head>
    <body>

        <div class="container">

            <div class="row">

                <div class="col-lg-8 col-lg-offset-2">

                   <img src="Evolve-4.jpg" width="750" height="300">

            <p class="lead">Tag line DemoTag line DemoTag line DemoTag line DemoTag line DemoTag line  </p>


                  

  <form  method="post" >
                       
                        <div class="controls">

                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="form_name">Employee Id *</label>
                                        <input id="form_name" type="text" name="emp_id" class="form-control" placeholder="Please enter your Employee Id *" required="required" data-error="Employee Id required.">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="form_lastname">Employee Name *</label>
                                        <input id="form_lastname" type="text" name="emp_name" class="form-control" placeholder="Please enter your Employee Name *" required="required" data-error="Employee Name is required.">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="form_email">Email *</label>
                                        <input id="form_email" type="email" name="email" class="form-control" placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="form_phone">Phone</label>
                                        <input id="form_phone" type="tel" name="phone" class="form-control" placeholder="Please enter your phone">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                            </div>
                            
                            
                            
                            
                             <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="form_email">Company Name *</label>
                                        <input id="form_email" type="company" name="company" class="form-control" placeholder="Please enter your Company Name *" required="required" data-error="Valid email is required.">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="form_phone">Delivery Address</label>
                                        <input id="form_phone" type="tel" name="del_add" class="form-control" placeholder="Please Enter Your Delivery Address">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="form_phone">Pin Code</label>
                                        <input id="form_phone" type="tel" name="pin_code" class="form-control" placeholder="Please Enter Your Pin Code">
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                            </div>
                            
                            
                            
                            
                            
                            
                            <div class="row">
                                <div class="col-md-5">
                                    <div class="form-group">
                                        <label for="form_message">Country *</label></br>
                                      <select name="country" class="countries" id="form-control">
<option value="">Select Country</option>
</select>
                                        
                                        
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="form_message">State *</label></br>
                                        
                                        <select name="state" class="states" id="form-control">
<option value="">Select State</option>
</select>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="form_message">City *</label></br>
                                        
                                        <select name="city" class="cities" id="form-control">
<option value="">Select City</option>
</select>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                </div>
                                
                                
                                
                                    
                                
                                 <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="form_message">Message *</label>
                                        <textarea id="form_message" name="message" class="form-control" placeholder="Message for me *" rows="4" required="required" data-error="Please,leave us a message."></textarea>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
                                </div>
                                
                                
                                
                                
                                <div class="col-md-12">
                                    <input type="submit" value="submit" name="submit" >
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <p class="text-muted"><strong>*</strong> These fields are required.</p>
                                </div>
                            </div>
                        </div>

                    </form>

                </div><!-- /.8 -->

            </div> <!-- /.row-->

        </div> <!-- /.container-->

        <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <script src="validator.js"></script>
        <script src="contact.js"></script>
    </body>
</html>

for Show on specific page create page name as show.php


<style>
input,textarea{width:200px}
input[type=submit]{width:100px}
</style>
<form method="post">

 
 <input type="submit" name="disp" value="Display Data"/>
 </td>
  </tr>
</table>
</form>
<?php
//mysqli connectivity
$connect= new mysqli("localhost","root","","dt50") or die("ERROR:could not connect to the database!!!!");
extract($_POST);

if(isset($disp))
{
 $query="select * from user";
 $result=$connect->query($query);
 echo "<table border=1>";
 echo "<tr><th>Employee Id</th><th>Employee Name</th><th>Email</th><th>Phone No</th><th>Company </th><th>Delivery Address</th><th>Pin Code</th><th>Country</th><th>State</th><th>City</th><th>Message</th></tr>";
 while($row=$result->fetch_array())
  {
  echo "<tr>";
  echo "<td>".$row['emp_id']."</td>";
  echo "<td>".$row['emp_name']."</td>";
  echo "<td>".$row['email']."</td>";
  echo "<td>".$row['phone']."</td>";
  echo "<td>".$row['company']."</td>";
  echo "<td>".$row['del_add']."</td>";
  echo "<td>".$row['pin_code']."</td>";
  echo "<td>".$row['country']."</td>";
  echo "<td>".$row['state']."</td>";
  echo "<td>".$row['city']."</td>"; 
  echo "<td>".$row['message']."</td>";
  echo "</tr>";
  }
 echo "</table>"; 
}

?>

Previous
Next Post »
Thanks for your comment