Ok i setup a database using the instructions on htmlgoodies... now it doesnt really say how to get info on there.. i mean sure it gives variables and codes. But it deosnt say where to apply the codes. it's very simple database... first name lastname and email. Now how do i write a script to send stuff to there?
ok sorry... bare with me i'm fairly new at all this database stuff.... Ok here is my scenario, I just learned how to make a table database (real basic) using Access (downloading SQL as we speak). Anyway, My database table consists of first_name last_name and email.. as per example of htmlgoodies database. Now the next section after making the database is inserting text into the database. How exactly do i Insert stuff into the required fields. Do i have to make an html page with certain values that tells the information where to be added into the database? My question basically is how do i send information to be collected to the database?
// Connect to database using variables already defined
mysql_connect($hostname, $db_user, $password);
// Input information in variables or stop script
$result = mysql_query($query) or die("MySQL Error");
That will put the values "Dave", "Clark", and "firstname.lastname@example.org" in the columns "firstname", "lastname", and "email". If the query fails, the die() function is called, which stops the script with an error message you specify. Obviously, you'll have to change the first four variables to fit your particular database, except for $hostname, which should be localhost in your case. If your database doesn't have a password, you can just omit that parameter from the mysql_connect() function call. Also, it's always smart to put these variables in a .php include file, for tighter security. Actually, because it seems you're hosting your own site, it would be even more logical to put the variables in a directory seperate from your web root, so that it can't be accessed at all outside of the script (and directly by you).
Note that this script assumes that MySQL is set up, that there is a database called "name of the database", and that there are three columns with appropriate names in that database. Setting up the database and tables can be done with another script, which I'll write for you if you want.