Home › Forums › Back End › Uploading Form Data to The Database › Reply To: Uploading Form Data to The Database
August 19, 2014 at 12:14 pm
#179860
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 -> 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 -> execute( array(
'TITLE'=>$title,
'COVER_URL'=>$cover_url,
'STARRING'=>$starring,
'DIRECTOR'=>$director,
'RUNTIME'=>$run_time,
'RELEASED'=>$released,
'RATING'=>$rating,
'PLOT_SUMMARY'=>$plot_summary,
'PERSONAL_OPINION'=>$personal_opinion,
'TRAILER'=>$trailer
) ) ) {
}
} catch( PDOException $e ) {
echo $e -> getMessage();
}
}
?>
`