My html form uses an upload.php file to create items in the database. The upload.php file automatically grabs the filesize, filetype and filename from the form without having to supply the items by coding manually. It was basically built from a tutorial I found online (yes, someone searched for answers before posting anything 😉 )
<?php
mysql_connect("SERVER","USERNAME","PASSWORD");
mysql_select_db("DATABASE");
$data = addslashes($form_data);
$result=MYSQL_QUERY("INSERT INTO baseline_doc_uploads (description, data, filename, filesize, filetype, doc_level, doc_sub_level, doc_name, doc_num_a, doc_num_b, doc_change_a, doc_change_b, doc_version_a, doc_version_b, doc_revision_a, doc_revision_b, doc_spcr_a, doc_spcr_b, doc_date_a, doc_date_b, doc_opr, doc_priority, doc_status, doc_hard_copy_only, doc_poc_1, doc_poc_2, doc_poc_3, doc_poc_4, doc_additional_comments ) ". "VALUES ('$form_description', '$data', '$form_data_name', '$form_data_size', '$form_data_type', '$doc_level', '$doc_sub_level', '$doc_name', '$doc_num_a', '$doc_num_b', '$doc_change_a', '$doc_change_b', '$doc_version_a', '$doc_version_b', '$doc_revision_a', '$doc_revision_b', '$doc_spcr_a', '$doc_spcr_b', '$doc_date_a', '$doc_date_b', '$doc_opr', '$doc_priority', '$doc_status', '$doc_hard_copy_only', '$doc_poc_1', '$doc_poc_2', '$doc_poc_3', '$doc_poc_4', '$doc_additional_comments')");
$id= mysql_insert_id();
print "<p>File ID: <b>$id</b><br>";
print "<p>File Name: <b>$form_data_name</b><br>";
print "<p>File Size: <b>$form_data_size</b><br>";
print "<p>File Type: <b>$form_data_type</b><p>";
?>
I have created a new html form that looks the same as the first one and prepopulates each field with the appropriate values according to the id and updates the MySQL file with a couple problems: it does not automatically grab the filesize, filetype and filename from the form. Instead of creating a UPDATE.php file, I thought I could use Dreamweaver to simplify things for me since I am so new to PHP. I know I have to put the values in manually, but here's what Dreamweaver gives me for code, at least the UPDATE part of it. How can I edit the code from Dreamweaver, or how can I edit my UPLOAD.PHP file to create an UPDATE.PHP file?
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE baseline_doc_uploads SET description=%s, `data`=%s, doc_level=%s, doc_sub_level=%s, doc_name=%s, doc_num_a=%s, doc_num_b=%s, doc_change_a=%s, doc_change_b=%s, doc_version_a=%s, doc_version_b=%s, doc_revision_a=%s, doc_revision_b=%s, doc_spcr_a=%s, doc_spcr_b=%s, doc_date_a=%s, doc_date_b=%s, doc_opr=%s, doc_priority=%s, doc_status=%s, doc_hard_copy_only=%s, doc_poc_1=%s, doc_poc_2=%s, doc_poc_3=%s, doc_poc_4=%s, doc_additional_comments=%s WHERE id=%s",
GetSQLValueString($_POST['form_description'], "text"),
GetSQLValueString($_POST['form_data'], "text"),
GetSQLValueString($_POST['doc_level'], "text"),
GetSQLValueString($_POST['doc_sub_level'], "text"),
GetSQLValueString($_POST['doc_name'], "text"),
GetSQLValueString($_POST['doc_num_a'], "text"),
GetSQLValueString($_POST['doc_num_b'], "text"),
GetSQLValueString($_POST['doc_change_a'], "text"),
GetSQLValueString($_POST['doc_change_b'], "text"),
GetSQLValueString($_POST['doc_version_a'], "text"),
GetSQLValueString($_POST['doc_version_b'], "text"),
GetSQLValueString($_POST['doc_revision_a'], "text"),
GetSQLValueString($_POST['doc_revision_b'], "text"),
GetSQLValueString($_POST['doc_spcr_a'], "text"),
GetSQLValueString($_POST['doc_spcr_b'], "text"),
GetSQLValueString($_POST['doc_date_a'], "text"),
GetSQLValueString($_POST['doc_date_b'], "text"),
GetSQLValueString($_POST['doc_opr'], "text"),
GetSQLValueString($_POST['doc_priority'], "text"),
GetSQLValueString($_POST['doc_status'], "text"),
GetSQLValueString(isset($_POST['doc_hard_copy_only']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['doc_poc_1'], "text"),
GetSQLValueString($_POST['doc_poc_2'], "text"),
GetSQLValueString($_POST['doc_poc_3'], "text"),
GetSQLValueString($_POST['doc_poc_4'], "text"),
GetSQLValueString($_POST['doc_additional_comments'], "text"),
GetSQLValueString($_POST['id'], "int"));