Forum Moderators: coopster
{
include("assets/includes/header.inc");// connects to the database and selects the table
echo ('<div id="primary">');?>
<?php
if(isset($_POST['go']))
{
$sql = "INSERT INTO cms_amazonmusic (title, link, description) VALUES ('$title','$link','$description')";
mysql_query($sql);
if(!mysql_error()){echo $title . " has been added to the database<br/><br/><a href=\"#\">add another</a>";
}
else
{
echo
('
<form method="post" action="'.$_SERVER["PHP_SELF"].'">
<p>title : <br/> <input type="text" id="title" name="title" ></p>
<p>amazon link : <br/><input type="text" id="link" name="link" /></p>
<p>description : <br/><input type="text" id="description" name="description" /></p>
<p><input type="submit" id="go" name="go" value="go" /></p>
</form>
');
}
}
<?php
include("assets/includes/header.inc");//I would suggest storing these functions in a file called header.php NOT header.inc because with an extension of .inc, the code can be viewed by anyone as plain text, therefore revealing your username and passwordecho "<div id='primary'>";
if(isset($_POST["go"]))
{
$sql = "INSERT INTO cms_amazonmusic (title, link, description) VALUES ('$title','$link','$description')";
$result = mysql_query($sql) or die("Information was not added");
if($result){echo $title . " has been added to the database<br/><br/><a href=\"#\">add another</a>";
}
else
{
echo "
<form method='post' action='".$_SERVER["PHP_SELF"]."'>
<p>title : <br/> <input type='text' id='title' name='title' ></p>
<p>amazon link : <br/><input type='text' id='link' name='link' /></p>
<p>description : <br/><input type='text' id='description' name='description' /></p>
<p><input type='submit' id='go' name='go' value='go' /></p>
</form>
";
}
?>