Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» Php Introduction
» Php Tutorials
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | Free PHP Tutorials


Adding data to a Database

In this first of our three part guide to manipulating data in a MySQL database we will add data to a MySQL database . First create our sample database.

Now create our sample table like this.

Now we have our table , what we will do is create a form which allows a user to add some text to the database in this we will make it a link. Here is the code for our form , this is pretty straightforward .

<form action="addingtoadb1.php" method ="POST">
<input type = "text" name = "add" maxlength="50"><br>
<input type = "submit" value = "add link"><br>
</form>

Now we move onto our php script , replace the ("hostname" , "username" , "password") with your own details .

<?php
//make our connection details
$connection = mysql_connect("hostname" , "username" , "password")
or die ("Cannot make the connection");
//connect to sampledb with our connection details
$db = mysql_selectdb("sampledb" , $connection)
or die ("Cannot connect to the database");
//if the text field wasnt blank enter data
if($add)
{
//insert the text box data into the sample table
$sql_query = "INSERT into sample VALUES ('','$add')";
$result = mysql_query($sql_query);
//display the entered link
echo "You entered the following info " . $add;
}
//if it was blank display a message
else
{
echo ("you didnt enter any data");
}
?>

This will add the text / link to the database , in our next part we will display the links in the database

[more] [1] [2] [3]

Recommended Webhosting Company
Domain Names
Looking to find domain names? Visit our domain names guide.

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Domain Names
 2. Domain Name Registratio
 3. Websites Hosting
 4. Find free web hosting
 5. Free Web Hosting
 
-
- Give us feedback
 
Last updated
Oct 11, 2008
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access