Data entry through PHP form

Discussion in 'Software' started by Bixo, Feb 4, 2009.

  1. Bixo

    Bixo Private E-2

    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:

    PHP:
    <? 

    $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?
     
  2. PC-XT

    PC-XT Master Sergeant

    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.)
     
  3. morfien

    morfien Private E-2

    <?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'];
     
  4. data entry

    data entry Private E-2

    Hi,
    I could understand the code but this is not the way you are earning money.
    I have visited data entry site and got some way to earn money. Not much but reasonable.

    Bye
    Best Data Entry Jobs Portal
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds