Hi,
I used php form generator to to create an input form that stores data in localhost. It has text fields and one file upload field which is field_8. When sending data, i get a feedback saying Notice: Undefined index: field_8 in C:\xampp\htdocs\form\processor.php on line 16.
Please help how to define this file upload field.
the code is as follows:
Hi,
I used php form generator to to create an input form that stores data in localhost. It has text fields and one file upload field which is field_8. When sending data, i get a feedback saying Notice: Undefined index: field_8 in C:\xampp\htdocs\form\processor.php on line 16.
Please help how to define this file upload field.
// File upload handlingthe code is as follows:
if($FILES['field_8']['name']!=''){
$field_8_filename = "file_8".date("sihdmY").substr($_FILES['field_8']['name'],strlen($_FILES['field_8']['name'])-4);
if(!move_uploaded_file($_FILES['field_8']['tmp_name'], "./files/".$field_8_filename)){
die("File " . $_FILES['field_8']['name'] . " was not uploaded.");
}
}
$link = mysql_connect($db_host="localhost",$db_user="root",$db_pass="",$db_name="exampledb");
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into
".$db_table."
(field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8)VALUES ('" . $_POST['field_1'] . "','" . $_POST['field_2'] . "','" . $_POST['field_3'] . "','" . $_POST['field_4'] . "','" . $_POST['field_5'] . "','" . $_POST['field_6'] . "','" . $_POST['field_7'] . "','" . $_POST['field_8'] . "')";
mysql_query($query);
mysql_close($link);
include("confirm.html");
?>
Last edit: safgom masese 2015-12-22