Tuesday, April 15, 2014

INSERT Values in Mysql table using php

In this post am going to explain how to write database connection and how to insert values in mysql table.Let's take a look .

Description

Insert values in mysql using php.it's very easy to insert values.
Functionality files:
1.Index.php
2.conn.php
3.insert.php


index.php

<div class="wrapContainer">
  <div class="codeContainer">
    <p class="Blue">
    <form id="formID" action="insert" name="registerform" method="pos">
      <p>
        <input type="text" name="name" value="" placeholder="Name"/>
      </p>
      <p>
        <input type="text" name="phonenumber" value="" "" placeholder="Phonenumber"/>
      </p>
      <p>
        <input type="text" name="address" value="" "" placeholder="Address"/>
      </p>
      <p>
        <input type="submit" name="submit" value=""/>
      </p>
    </form>
  </div>
</div>

conn.php

  
  <?php
$conn=mysql_connect("localhost","root","")or die('Database not connected');
$db=mysql_select_db("Your Database")or die('Database not connected');
?>



insert.php

  <?php
if(isset($_POST['submit']))
{
$name=$_POST['namename'];
$number=$_POST['phonenumber'];
$address=$_POST['address'];
$insert=mysql_query("insert into ddtable(name,number,address)values('$name','$number','$address')");
}
?>

No comments:

Post a Comment