Ran into some more trouble
<?php
if ( isset( $_POST['submit'] )) {
$server = "localhost"; // domæne
$brugernavn = "files"; // username
$password = "**********"; // password
$db_navn = "fileindex"; // name of database
$dbt_navn = "yourtablename"; // navn of table in the database
mysql_connect($server, $brugernavn, $password)
or die( "Unable to connect\n". mysql_error() );
mysql_select_db("$db_navn")
or die("Unable to select db ".mysql_error()."\n");
$title = $_POST['title'];
$url = $_POST['url'];
$category = $_POST['category'];
$res = mysql_query( "
SELECT COUNT( * )
FROM $dbt_navn
WHERE url = '$url'
");
if ( mysql_result( $res, 0, 0 )) {
// The given url is already in the database. shoould we proceed and insert it again ?
}
mysql_query( "
INSERT INTO $dbt_navn
VALUES (0, '$title', '$url', $category)
");
if ( mysql_affected_rows() == 0 ) {
// could not insert, one of the fields had not been filled.
}
} // end of the IF statement
?>
<html>
<head></head>
<body>
<form method='post' action="content.php?var=indexscript">
<input name='title' type='text' value="Title">
<input name='url' type='text' value="URL">
<SELECT name='category'>
<option value='1'>Flash Movies</option>
<option value='2'>Flash Games</option>
<option value='3'>Videos</option>
</select>
<input name='submit' type="submit" value="Send it">
</form>
</body>
</html>
This is the script I use to add files onto the db, which is then pulled by the other script.
I ran into a couple mysql errors with this one as well, but I was able to fix them, however, now whenever I submit something, it goes back to indexscript (this one) which it should, but it doesnt show up on any of the pages.