Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to store date to database

Answer Posted / kannan

Step for store data to database
1.insert.php
2.insert_ac.php
3.edit.php
4.delete.php
5.update.php
5.update_ac.php

1insert.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
db".mysql_error());
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div align="center" style="float:left;width:400px;">
<form method="post" action="insert_ac.php">
<table border="1" cellpadding="10" cellspacing="4" width="400">
<tr>
<td colspan="3" align="center" width="100%">Enter Customer
Infomation</td>
</tr>
<tr>
<td align="left" width="40%">Name</td>
<td align="center" width="10%">:</td>
<td align="left" width="50%"><input type="text" name="name"
/></td>
</tr>
<tr>
<td align="left" width="40%">Last Name</td>
<td align="center" width="10%">:</td>
<td align="left" width="50%"><input type="text"
name="lastname" /></td>
</tr>
<tr>
<td align="left" width="40%">Email</td>
<td align="center" width="10%">:</td>
<td align="left" width="50%"><input type="text" name="email"
/></td>
</tr>
<tr>
<td align="left" width="40%"><input type="submit"
value="SUBMIT" name="submit" /></td>
<td align="center" width="10%">&nbsp;</td>
<td align="left" width="50%"><a href="edit.php"
target="_blank">Edit</a></td>
</tr>
</table>
</form><br /><br />
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>

</div>

</body>
</html>

2.insert_ac.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
dn".mysql_error());

$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];

$sql = "insert into test_mysql(name,lastname,email)
values('$name','$lastname','$email')";
$result = mysql_query($sql);
if($result!=""){
echo "Record successfuly added"." "."<a
href='insert.php'>Back</a>";
}
else{
echo "failed";
echo "<br>";
}
?>
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>
3.edit.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
db".mysql_error());

$sql = "select * from test_mysql";
$result = mysql_query($sql);
echo "<table border='1' cellpadding='10' cellspacing='4'
width='400'>";
while($res = mysql_fetch_array($result)){
$id = $res['id'];
$name = $res['name'];
$lastname = $res['lastname'];
$email = $res['email'];
echo
"<tr><td>$id</td><td>$name</td><td>$lastname</td><td>$email</td><td><a
href='delete.php?id=$id'>Delete</a></td><td><a
href='update.php?id=$id'>Update</a></td></tr>";
}
echo "</table>";
echo "<br>";
?>
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>
4.delete.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
dn".mysql_error());

$id = $_GET['id'];

$sql = "delete from test_mysql where id='$id'";
$result = mysql_query($sql);
if($result!=""){
echo "Record successfuly delete"." "."<a
href='edit.php'>Back</a>";
}
else{
echo "failed";
echo "<br>";
}
?>
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>
5.update.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
dn".mysql_error());

$id = $_GET['id'];
$sql = "select * from test_mysql where id='$id'";
$result = mysql_query($sql);
echo "<form method='post' action='update_ac.php?id=$id'>";
echo "<table border='1' cellpadding='10' cellspacing='4'
width='400'>";
while($res = mysql_fetch_array($result)){
$id = $res['id'];
$name = $res['name'];
$lastname = $res['lastname'];
$email = $res['email'];

echo "<tr><td><input type='text' name='id'
value='$id'></td><td><input type='text' name='name'
value='$name'></td><td><input type='text' name='lastname'
value='$lastname'></td><td><input type='text' name='email'
value='$email'></td><td><input type='submit' name='submit'
value='submit'></td></tr>";
}
echo "</table>";
echo "</form>";
echo "<br>";
?>
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>
6.update_ac.php
<?php
$con = mysql_connect("localhost","root","") or die("could
not connect".mysql_error());
$db = mysql_select_db("sekar") or die("could not select
dn".mysql_error());

$id = $_REQUEST['id'];
$name = $_REQUEST['name'];
$lastname = $_REQUEST['lastname'];
$email = $_REQUEST['email'];

$sql = "update test_mysql set id='$id', name='$name',
lastname='$lastname', email='$email' where id='$id'";
$result = mysql_query($sql);
if($result!=""){
echo "Record successfuly updated"." "."<a
href='edit.php'>Back</a>";
}
else{
echo "failed";
echo "<br>";
}
?>
<ul>
<li><a href="insert.php">Add New record</a></li>
<li><a href="edit.php">View record</a></li>
</ul>

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me how is it possible to parse a configuration file?

942


How to select a database?

1022


How send email using php?

971


How To Get the Uploaded File Information in the Receiving Script?

1033


What is multidimensional array in php?

1010


Explain the types of string comparision function in PHP

947


How to check an key is exists in array?

1086


What is the difference between $argv and $argc? Give example?

989


Is a number php?

990


What are the different types of array in php?

983


What does the array operator '===' means?

1051


What is the role of php.ini file?

995


How can we automatically escape incoming data?

988


What are the common uses of php?

1102


How can you send http header to the client in php?

1016