sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 they would not be in the database again if you would look here I think that you would see what I am trying to do. this is what I was using but it was just writing to a php file. It is for the admin only other customers wont see it and they are requesting information so I have never heard of them until they fill out the form. http://www.sandbudd.com/image/email.php Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 5, 2008 Share Posted July 5, 2008 Oh. Where are you storing the rest of the client information? Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 in the same table just havent built all that yet it would all go under the same id Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 if this helps here is the code I was using to write to the file. If we can figure out how to write it to a database that would be great! <?php error_reporting(0); session_start(); $Domain="http://".$_SERVER['HTTP_HOST']; $fname=$_POST['fname']; $company=$_POST['company']; $address=$_POST['address']; $city=$_POST['city']; $zip=$_POST['zip']; $email=$_POST['email']; $phone=$_POST['phone']; $fax=$_POST['fax']; $type2=$_POST['type2']; $type3=$_POST['type3']; $burnishing=$_POST['burnish']; $chromate=$_POST['chromate']; $hex=$_POST['hex']; $impregnation=$_POST['impregnation']; $impregnation=$_POST['strip']; $part_number=$_POST['part_number']; $part_description=$_POST['part_description']; $specifications=$_POST['specifications']; $repeat=$_POST['repeat']; $internet_search=$_POST['internet_search']; $internet_directory=$_POST['internet_directory']; $referral=$_POST['referral']; $yellow_pages=$_POST['yellow_pages']; $trade_show=$_POST['trade_show']; $other=$_POST['other']; $notes=$_POST['notes']; $cdir="rfq"; $save_path="uploads/"; $date = date("F j, Y, g:i a"); $file = $_FILES['userfile']; $k = count($file['name']); for($i=0;$i< $k ;$i++) { if(isset($save_path) && $save_path!="") { $random_digit=rand(0000,9999999); $name = split('/',$file['name'][$i]); $name = str_replace("\\","",$name); $name = str_replace("'","",$name); $name = str_replace("","_",$name); $name = str_replace(" ","_",$name); $name = str_replace(".",$random_digit.".",$name); if(move_uploaded_file($file['tmp_name'][$i], $save_path . $name[count($name)-1])) { //// download the file///// $finalfile.="<li><a href='".$Domain."/".$cdir."/download.php?f=".$name[count($name)-1]."'>".$name[count($name)-1]."</a></li>"; $list_files.="<li>".$name[count($name)-1]."</li>"; } } } ///message in the mail////// $msg="-- This is the Customer's information -- <br>Full Name: $fname <br>Company: $company <br>Address: $address <br>City: $city <br>State: $State <br>Zip: $zip <br>Email: <a href='mailto:$email'>$email<a> <br>Phone Number: $phone <br>Fax Number: $fax <br>Process Requested? <br>$type2 $type3 $burnish $chromate $hex $impregnation $strip <br>Part Number: $part_number <br>Part Description: $part_description <br>Alloy: $alloy <br>Quantity: $quantity <br>Specifications: $specifications <br>Color: $color <br>How did you hear about us? <br>Repeat: $repeat <br>Internet Search: $internet_search <br>Internet Directory: $internet_directory <br>Referral: $referral <br>Yellow Pages: $yellow_pages <br>Trade Show: $trade_show <br>Other: $other <br>Notes: $notes <br><br>Attached files: $finalfile"; $msg2=" <br>----------------------------------------------------- <br> <br>-- Clients information Submitted $date --<br> <br>Full Name: $fname <br>Company: $company <br>Address: $address <br>City: $city <br>State: $State <br>Zip: $zip <br>Email Address: <a href='mailto:$email'>$email<a> <br>Phone Number: $phone <br>Fax Number: $fax <br>Process Requested? $type2 $type3 $burnish $chromate $hex $impregnation $strip <br>Part Number: $part_number <br>Part Description: $part_description <br>Alloy: $alloy <br>Quantity: $quantity <br>Specifications: $specifications <br>Color: $color <br>How did you hear about us? <br>Repeat: $repeat <br>Internet Search: $internet_search <br>Internet Directory: $internet_directory <br>Referral: $referral <br>Yellow Pages: $yellow_pages <br>Trade Show: $trade_show <br>Other: $other <br>Notes: $notes <br><br>Attached files: <br>$finalfile <br>"; ///email address//// $to = "dan@sandbudd.com"; ///Subject Title $subject="New Message"; $headers = "From: $email\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"; //mail Function////// mail($to,$subject,$msg,$headers); $fh = fopen("email.php", "a"); fwrite($fh, $msg2); fclose($fh); ?> Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 I know how to build the rest of the database and code just the multiple file upload I cant grasp. Quote Link to comment Share on other sites More sharing options...
ron8000 Posted July 5, 2008 Share Posted July 5, 2008 Just wanted to know if you are still having probs, sorry about this morning needed to get at least an hr of sleep still got a lot of work to do very busy building a GUI framework but just post and let me know if you still need help Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 Ron still having a boat load of problems...lol...we got it to upload multiple files to the server and put them in the database but I need them to be under the same id? Please help if you can... Quote Link to comment Share on other sites More sharing options...
ron8000 Posted July 5, 2008 Share Posted July 5, 2008 my suggestion is to use the session id as your unique id... this is not the best method imo but it's the easiest another suggestion is to crate a table with 1 col for each file and file info that you want to store So both files form one person will go in one row and you can just set a max number of files and make that the max number of fields in the db... Other then thos 2 suggestions you need to create a user system that will give them an id and you can use that id form the user table and ref it like that So joe signs up for w/e and he's given a login or just a code w/e he uses that to upload the times and you can ref him in the user DB as the sender of the files... If this is not clear just let me know and i'll see if i can't clear it up for you Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 5, 2008 Author Share Posted July 5, 2008 Hey Ron thanks for responding. The problem has been getting the uploaded files address to show under one user id (if someone uploads 5 files). The code that I have uploads them to the server then does call them to the db but puts them in seperate id's Quote Link to comment Share on other sites More sharing options...
ron8000 Posted July 6, 2008 Share Posted July 6, 2008 I'm not sure you are following. 1. When you define a auto-increment field it will ALWAYS give a unique id. 2. When you are trying to make things relitave to another there HAS to be a common ground between the two. a simple solution to your problem is to give the table a new field called session_id. use that to store the session_id() when the file is uploaded. this will give you a way to get the files form the same user. this will also on the other hand, if a user is uploading more then one quote at durring any given session the id will be the same and not work for you. there is still hope with this method tho, if you destory the session and generate a new session_id when the form is completed, you will not have that problem. ^^ let me know if we are making progress! Learning is hard but the rewards are GREAT! Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 7, 2008 Author Share Posted July 7, 2008 ron I have created the field in db called session_id but I have no idea how to do the other stuff you suggested? sorry could you or someone explain in more detail what I have to do or show me please. Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 7, 2008 Author Share Posted July 7, 2008 changed to this and I get this error... I added to the db fields images, images1 it does upload the files but does not populate the database? array(2) { ["file1"]=> array(5) { ["name"]=> string(18) "Hawaii2008 005.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpq7jqEn" ["error"]=> int(0) ["size"]=> int(1306074) } ["file2"]=> array(5) { ["name"]=> string(18) "Hawaii2008 006.jpg" ["type"]=> string(10) "image/jpeg" ["tmp_name"]=> string(14) "/tmp/phpklNC4y" ["error"]=> int(0) ["size"]=> int(1337656) } } Notice: Undefined variable: upload_feedback in /home/anodizi/public_html/image/upload2.php on line 48 Notice: Undefined variable: upload_feedback in /home/anodizi/public_html/image/upload2.php on line 48 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''upload' ('attachment') VALUES(' Array~Array~')' at line 1 <?php error_reporting(E_ALL); ?> <?php $db_host = ''; $db_user = ''; $db_pwd = ''; $database = ''; $table = ''; $upload_feedback = ''; var_dump($_FILES); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $dest = 'upload/'; if(isset($_FILES) && !empty($_FILES) && is_array($_FILES)) { foreach($_FILES as $file) { $upload_msg[$file['name']] = move_upload($file, $dest); } } function move_upload( $file, $dest, $overwrite = false ) { if ($file["error"] == UPLOAD_ERR_OK) { if(!file_exists( $dest.$file["name"] ) || $overwrite) { if(move_uploaded_file( $file["tmp_name"], $dest.$file["name"] )) { $upload_feedback .= "The file " . $file["name"] . " was successfully uploaded"; $error = FALSE; } else { $upload_feedback .= "The file " . $file["name"] . " could not be moved"; $error = TRUE; } } else { $upload_feedback .= "The file " . $file["name"] . " already exists, please check the overwrite option if you wish to replace it"; $error = TRUE; } } else { switch ($file["error"]) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $upload_feedback .= "The file " . $file["name"] . " is to large to be uploaded<br />"; $error = TRUE; break; case UPLOAD_ERR_PARTIAL: $upload_feedback .= "The file" . $file["name"] . " was interrupted while uploading, please try again<br />"; $error = TRUE; break; } } return array( "error" => $error, "feedback" => $upload_feedback ); //return message plus error status } ?> <?php $images = " " ; foreach ($_FILES as $file) { $images .= $file."~" ; } mysql_query("INSERT INTO 'upload' ('attachment') VALUES('$images')") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
sandbudd Posted July 7, 2008 Author Share Posted July 7, 2008 wow what a pain but got it working and here is the final code thanks everyone <?php error_reporting(E_ALL); ?> <?php $db_host = ''; $db_user = ''; $db_pwd = ''; $database = ''; $table = ''; $upload_feedback = ''; var_dump($_FILES); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $dest = 'upload/'; if(isset($_FILES) && !empty($_FILES) && is_array($_FILES)) { foreach($_FILES as $file) { $upload_msg[$file['name']] = move_upload($file, $dest); } } function move_upload( $file, $dest, $overwrite = false ) { if ($file["error"] == UPLOAD_ERR_OK) { if(!file_exists( $dest.$file["name"] ) || $overwrite) { if(move_uploaded_file( $file["tmp_name"], $dest.$file["name"] )) { $upload_feedback .= "The file " . $file["name"] . " was successfully uploaded"; $error = FALSE; } else { $upload_feedback .= "The file " . $file["name"] . " could not be moved"; $error = TRUE; } } else { $upload_feedback .= "The file " . $file["name"] . " already exists, please check the overwrite option if you wish to replace it"; $error = TRUE; } } else { switch ($file["error"]) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $upload_feedback .= "The file " . $file["name"] . " is to large to be uploaded<br />"; $error = TRUE; break; case UPLOAD_ERR_PARTIAL: $upload_feedback .= "The file" . $file["name"] . " was interrupted while uploading, please try again<br />"; $error = TRUE; break; } } return array( "error" => $error, "feedback" => $upload_feedback ); //return message plus error status } ?> <?php $f_1 = $_FILES['file1']['name'] ; $f_2 = $_FILES['file2']['name'] ; mysql_query("INSERT INTO upload (image1,image2) VALUES('$f_1','$f_2')") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.