Heres my script:
<? include("header.php"); ?>
<br>
<br>
<center>
<img src="http://www.tinkerbell.ws/images/links.gif">
</center>
<?php
$db = mysql_connect("localhost","username","password");
//The function mysql_select_db() sets the current
//databse to the one specified in this case "samplelinks"
mysql_select_db("voogru_tinkerbell" ,$db);
$sqlquery = mysql_query("SELECT * FROM links" ,$db);
echo " <center>\n";
echo "<table border ='0' bgcolor=\"#9999FF\" cellspacing=\"1\" width=\"60%\">\n";
echo " <tr> \n";
echo " <td bgcolor=\"#000000\"><b><font color=\"#FFFF00\">Link</font></b></td>\n";
echo " <td bgcolor=\"#000000\"><font color=\"#FFFF00\"><b>Description</b></font></td>\n";
while ($tablerows = mysql_fetch_row($sqlquery))
{
echo " </tr>\n";
echo " <tr> \n";
echo " <td bgcolor=\"#000000\"><a href='$tablerows[0]'>$tablerows[0]</a></td>\n";
echo " <td bgcolor=\"#000000\"><font color=\"#FFFF00\">$tablerows[1]</font></td>\n";
echo " </tr>\n";
}
//close the database
echo "</table>";
echo " </center> \n";
?>
<center>
<form action="links.php" method ="POST">
Link: <input type = "text" name = "url" class=voo_input maxlength="50"><br>
Description: <input type = "text" name = "description" class=voo_input maxlength="50"><br>
<input type = "submit" value = "Add Link" class="voo_input"><br>
</form>
</center>
<? include("footer.php"); ?>
<?
//make our connection details
$connection = mysql_connect("localhost" , "username" , "password")
or die ("Cannot make the connection");
//connect to sampledb with our connection details
if($url)
$sql_query = "INSERT into links VALUES ('','$url')";
$result = mysql_query($sql_query);
if($description)
$sql_query = "INSERT into links VALUES ('','$description')";
$result = mysql_query($sql_query);
?>
Im trying to get it to allow people to add there own links to my database however i know there is something wrong and i hope someone could lead me in the right direction or point out and fix what i did wrong.
any help will be great 🙂