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 / dev

for database connectivity

<?php
$con = mysql_connect("localhost","your database username
here","your database password here") or die("could
not connect".mysql_error());
$db = mysql_select_db("your database name here") or die
("could not select db".mysql_error());
?>

insert into a table

$sql_query= "insert into your table name here(table fields
name here)
values(Fields values here)";
$result = mysql_query($sql_query);
?>

FOR EXAMPLE....

<?php
//for database connectivity
$con = mysql_connect("localhost","peter","123456");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}


mysql_select_db("my_db", $con); // select a database

$firstname=$_POST['firstname'];
$lastname = $_POST['lastname'];

// insert into a table
mysql_query("INSERT INTO Persons (FirstName, LastName)
VALUES ('$firstname','lastname ')");

mysql_close($con);
?>

<html>
<body>

<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
<input type="submit" />
</form>

</body>
</html>

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are php session secure?

992


List few sensible functions in PHP?

939


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

1849


Steps for the payment gateway processing?

955


Tell me can you extend a final defined class?

984


How to open a file for writing?

1001


What are the php functions?

977


What type of operation is needed when passing values through a form or an url?

921


Why framework is used in php?

938


What are the functions of string?

940


What is php full form?

971


How to read and display a HTML source from the website url?

923


How to increase the execution time of a PHP script?

979


Which function is used to strip whitespace?

910


What is php artisan tinker?

920