Create the PHP
Now it is time to send your information to the database for storage to be used at a different time. As in the previous exercise where you wrote a php script to e-mail the code, now you'll use a script to insert the form data into your database.
You will link the code to your page by listing the php page as the action in your form tag.
Here's the code:
<?php
// first let's set up a couple of functions
//connect to server and select database; you may need it
$conn = mysql_connect("localhost", "yourusernamegoeshere", "coyote");
//select the database to use
mysql_select_db("yourdatabasenamegoeshere", $conn) or die(mysql_error());
//create the SQL statement
$sql="insert into info values ('$_POST[fname]', '$_POST[lname]', '$_POST[ecolor]', '$_POST[song]')";
//execute the sql statement
$result=mysql_query($sql, $conn) or die(mysql_error());
print "Thanks $_POST[name], your information has been added to the database ";
?>
Assignment:
Create a new database and enter the information from your business into it.