Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Uploading Form Data to The Database Reply To: Uploading Form Data to The Database

#179860
Anonymous
Inactive

I fixed that and also i had INSER instead of INSERT. But now im getting all as “undefined index” and Invalid parameter number: parameter was not defined. Not sure whats causing this error.

`
<?php

//submit data to database
if(isset($_POST['upload'])) {

    $title = $_POST['TITLE'];
    $cover_url = $_POST['COVER_URL'];
    $starring = $_POST['STARRING'];
    $director = $_POST['DIRECTOR'];
    $run_time = $_POST['RUNTIME'];
    $released = $_POST['RELEASED'];
    $rating = $_POST['RATING'];
    $plot_summary = $_POST['PLOT_SUMMARY'];
    $personal_opinion = $_POST['PERSONAL_OPINION'];
    $trailer = $_POST['TRAILER'];

    try {

        include("host-connect.php");

        // prepare statement for insert
        $insert = $connect -&gt; prepare("INSERT INTO movies(TITLE, COVER_URL, STARRING, DIRECTOR, RUNTIME, RELEASED, RATING, PLOT_SUMMARY, PERSONAL_OPINION, TRAILER) VALUES (:TITLE, :COVER_URL, :STARRING, :DIRECTOR, :RUN_TIME, :RELEASED, :RATING, :PLOT_SUMMARY, :PERSONAL_OPINION, :TRAILER)");

        // insert using values from post
        if( $insert -&gt; execute( array(
            'TITLE'=&gt;$title,
            'COVER_URL'=&gt;$cover_url,
            'STARRING'=&gt;$starring,
            'DIRECTOR'=&gt;$director,
            'RUNTIME'=&gt;$run_time,
            'RELEASED'=&gt;$released,
            'RATING'=&gt;$rating,
            'PLOT_SUMMARY'=&gt;$plot_summary,
            'PERSONAL_OPINION'=&gt;$personal_opinion,
            'TRAILER'=&gt;$trailer
        ) ) ) {

        }

    } catch( PDOException $e ) {

        echo $e -&gt; getMessage();

    }

}

?>

`