Jump to content

[SOLVED] sends the email and populates the database great


sandbudd

Recommended Posts

sends the email and populates the database but the link to download the images shows as example

 

<a href=http://www.company.com/rfq/uploads/Hawaii2008_0184462635.jpg>Hawaii2008_0184462635.jpg</a>

 

rather than clickable Hawaii2008_0184462635.jpg

 

this was working just fine and started doing this.

 


<?php


error_reporting(0);


session_start();


$db_host = ''; 


$db_user = ''; 


$db_pwd = '';


$database = '';


$table = 'ae_gallery';








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");


      


$Domain="http://".$_SERVER['HTTP_HOST'];


$customer = mysql_real_escape_string($_POST['customer']);


$company=mysql_real_escape_string($_POST['company']);


$address=mysql_real_escape_string($_POST['address']);


$city=mysql_real_escape_string($_POST['city']);


$state=mysql_real_escape_string($_POST['state']);


$zip_code=mysql_real_escape_string($_POST['zip_code']);


$email=mysql_real_escape_string($_POST['email']);


$phone=mysql_real_escape_string($_POST['phone']);


$fax=mysql_real_escape_string($_POST['fax']);


$type2=mysql_real_escape_string($_POST['type2']);


$type3=mysql_real_escape_string($_POST['type3']);


$burnish=mysql_real_escape_string($_POST['burnish']);


$chromate=mysql_real_escape_string($_POST['chromate']);


$hex=mysql_real_escape_string($_POST['hex']);


$impregnation=mysql_real_escape_string($_POST['impregnation']);


$strip=mysql_real_escape_string($_POST['strip']);


$part=mysql_real_escape_string($_POST['part']);


$description=mysql_real_escape_string($_POST['description']);


$alloy=mysql_real_escape_string($_POST['alloy']);


$quantity=mysql_real_escape_string($_POST['quantity']);


$spec=mysql_real_escape_string($_POST['spec']);


$color=mysql_real_escape_string($_POST['color']);


$repeat_customer=mysql_real_escape_string($_POST['repeat_customer']);


$isearch=mysql_real_escape_string($_POST['isearch']);


$idirectory=mysql_real_escape_string($_POST['idirectory']);


$referral=mysql_real_escape_string($_POST['referral']);


$yellow_pages=mysql_real_escape_string($_POST['yellow_pages']);


$trade=mysql_real_escape_string($_POST['trade']);


$other=mysql_real_escape_string($_POST['other']);


$notes=mysql_real_escape_string($_POST['notes']);


$finalfile=mysql_real_escape_string($_FILES['finalfile']);











$cdir="rfq/uploads";


$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.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1].">".$name[count($name)-1]."</a>";


            $list_files.="<li>".$name[count($name)-1]."</li>";





}


      }


      }


      


      


      ///message in the mail//////


      $msg="-- This is the Customer's information -- \r\n


      Full Name: $customer\r\n


      Company: $company\r\n


      Address: $address\r\n


      City: $city\r\n


      State: $state\r\n


      Zip: $zip_code\r\n


      Email: $email\r\n


      Phone Number: $phone\r\n


      Fax Number: $fax\r\n


      Process Requested?\r\n


      $type2\r\n


      $type3\r\n


      $burnish\r\n


      $chromate\r\n


      $hex\r\n


      $impregnation\r\n


      $strip\r\n


      Part Number: $part\r\n


      Part Description: $description\r\n


      Alloy: $alloy\r\n


      Quantity: $quantity\r\n


      Specifications: $spec\r\n


      Color: $color\r\n


      How did you hear about us?\r\n


      Repeat: $repeat\r\n


      Internet Search: $isearch\r\n


      Internet Directory: $idirectory\r\n


      Referral: $referral\r\n


      Yellow Pages: $yellow_pages\r\n


      Trade Show: $trade\r\n


      Other: $other\r\n


      Notes: $notes\r\n


      Attached files:\r\n


      $finalfile";


      


      


      ///email address////


      $to =  "[email protected]";


            


      ///Subject Title


      $subject="New Message";


      


      //$headers = "From: $email\n";


      $headers = "From: $email" . "\r\n" . "CC: [email protected]";


      


      if(mail($to,$subject,$msg,$headers))





?>


<?php


{


      


        	





mysql_query("INSERT INTO ae_gallery (customer,company,address,city,state,zip_code,email,phone,fax,type2,type3,burnish,chromate,hex,impregnation,strip,part,description,alloy,quantity,spec,color,repeat_customer,isearch,idirectory,referral,yellow_pages,trade,other,notes,finalfile) VALUES('$customer','$company','$address','$city','$state','$zip_code','$email','$phone','$fax','$type2','$type3','$burnish','$chromate','$hex','$impregnation','$strip','$part','$description','$alloy','$quantity','$spec','$color','$repeat_customer','$isearch','$idirectory','$referral','$yellow_pages','$trade','$other','$notes','$finalfile')") or die(mysql_error());


      }


      


      ?>

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1].">".$name[count($name)-1]."</a>";

 

change ^^ to

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1]."><img src='".$name[count($name)-1]."' /></a>";

RussellReal now I get this error

 

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 'Hawaii2008_0184646126.jpg' />')' at line 1

 

plus it may not always be an image that is uploaded.

Instead of:

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1]."><img src='".$name[count($name)-1]."' /></a>";

 

use:

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1]."><img src=".$name[count($name)-1]." /></a>";

Instead of:

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1]."><img src='".$name[count($name)-1]."' /></a>";

 

use:

 

$finalfile.="<a href=".$Domain."/".$cdir."/".$name[count($name)-1]."><img src=".$name[count($name)-1]." /></a>";

 

yours isn't valid html? :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.