PDA

View Full Version : Data entry through PHP form


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?

PC-XT
02-13-09, 12:38
To see what's going on, you can try temporarily putting error_reporting(1023); at the top of the PHP code and removing the @ sign to display all errors/notices. If you still get nothing, the script is probably not being run. Perhaps the session is not being propagated correctly? It could also be some other technicality. (I did notice the $genre line was not completed.)

morfien
03-04-09, 14:06
<?php

$hostname = "locahost";
$username = "235301";
$password = "235301";
$database = "235301";

function showerror()
{
die("Error" .mysql_errno() . " : " . mysql_error());
exit;
}

$connection= mysql_connect($hostname, $username, $password);
$select_db= mysql_select_db($database, $connection) or showerror();


$film = $_POST['name'];
$year = $_POST['year'];
$genre = $_POST['genre'];

$sql ="INSERT INTO FILMS(filmname, filmyear, filmgenre) VALUES ('".$film."', '".$year."', '".$genre."')";

$sqlexecute=mysql_query($sql) or showerror();
?>

that should do the trick...

you must learn to look at your code much closer. the smallest spelling mistake could cause the whole script to stop working.

e.g

$sql ="INSERT INTO FILMS(filmname, filmyear, filmgenre)
VALUES ('".$film."', '".$jyear."', '".$genre."')";

your variable is:
$jaar = $_POST['year'];

data entry
06-19-09, 13:54
Hi,
I could understand the code but this is not the way you are earning money.
I have visited data entry (http://www.sysexecutive.com/data-entry/how-to-find-an-online-job-doing-data-entry) site and got some way to earn money. Not much but reasonable.

Bye
Best Data Entry Jobs Portal