Bixo
02-04-09, 08:31
I have used the search option prior to making this new thread in order to find an answer to my question but I couldn't quite find what I was looking for.
Here is my problem.
I've made a website in PHP in which it is possible to search for data which is stored in a phpMyadmin database. This data is categorised in several different categories.
I have also made a seperate page which is only accescible by password.
What I'd like to do is to make it possible to add more data to the database from the website itself (after having logged in with the password) via a form.
The whole logging in thing works just fine but I haven't got a clue how to make it possible to add more data with a form.
So far this is a script I have found and used but it doesn't quite work:
<?
$hostname = "locahost";
$username = "235301";
$password = "235301";
$database = "235301";
function showerror()
{
die("Error" .mysql_errno() . " : " . mysql_error());
exit;
}
if (!($connection= @ mysql_connect($hostname, $username, $password))) showerror();
if (!mysql_select_db($database, $connection))
showerror();
$film = $_POST['name'];
$jaar = $_POST['year'];
$genre = $_POST['genre'
$sql ="INSERT INTO FILMS(filmname, filmyear, filmgenre)
VALUES ('".$film."', '".$jyear."', '".$genre."')";
if (!($temp = mysql_query($sql,$connection)))
showerror();
?>
In fact this script doesn't work at all, it doesn't do anything.
After having used the form I check my database but nothing is added.
What is wrong with the script so I can make it work properly?
Here is my problem.
I've made a website in PHP in which it is possible to search for data which is stored in a phpMyadmin database. This data is categorised in several different categories.
I have also made a seperate page which is only accescible by password.
What I'd like to do is to make it possible to add more data to the database from the website itself (after having logged in with the password) via a form.
The whole logging in thing works just fine but I haven't got a clue how to make it possible to add more data with a form.
So far this is a script I have found and used but it doesn't quite work:
<?
$hostname = "locahost";
$username = "235301";
$password = "235301";
$database = "235301";
function showerror()
{
die("Error" .mysql_errno() . " : " . mysql_error());
exit;
}
if (!($connection= @ mysql_connect($hostname, $username, $password))) showerror();
if (!mysql_select_db($database, $connection))
showerror();
$film = $_POST['name'];
$jaar = $_POST['year'];
$genre = $_POST['genre'
$sql ="INSERT INTO FILMS(filmname, filmyear, filmgenre)
VALUES ('".$film."', '".$jyear."', '".$genre."')";
if (!($temp = mysql_query($sql,$connection)))
showerror();
?>
In fact this script doesn't work at all, it doesn't do anything.
After having used the form I check my database but nothing is added.
What is wrong with the script so I can make it work properly?