Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I am new with PHP and I love it... I made my first form today a really big one...everything works great so I can make my other 8 forms... but then I thought it would be great if the visitor could attach images along with the form... here is my code...Code: Select all
<?php
// list all vars to be expected from the movie
$vars = array("name", "title", "company", "address", "city", "telephone", "fax", "email", "aoutdiam", "aoutdiaminch", "boutdiam", "boutdiaminch", "boutdiamp", "boutdiampinch", "coutdiam", "coutdiaminch", "aindiam", "aindiaminch", "bindiam", "bindiaminch", "bindiamp", "bindiampinch", "cindiam", "cindiaminch", "load1", "load1lbs", "load1p", "load1plbs", "load1at", "load1atlbs", "load2", "load2lbs", "load2p", "load2plbs", "load2at", "load2atlbs", "rate", "ratelbs", "ratep", "rateplbs", "ratebetween", "ratebetweeninch", "ratebetweenand", "ratebetweenandinch", "maxextlength", "maxextlengthinch", "relativeloop", "dirwind", "type", "alengthmax", "alengthmaxinch", "alengthmin", "alengthmininch", "blength", "blengthinch", "blengthp", "blengthpinch", "clength", "clengthinch", "wirediam", "wirediaminch", "coildiam", "coildiaminch", "activecoils", "bodylength", "bodylengthinch", "initialtension", "initialtensionlbs", "quanityquote", "typematerial", "othertypematerial", "finish", "operatingtemp", "operatingtemptype", "enduse", "other", "file1");
// and import them into the script
foreach($vars as $var)
if(isset($_POST[$var]))
$$var = $_POST[$var];
else
$$var = '';
// check variables
if(strlen($name) < 1)
die("Please Click your Browser's Back button and Enter a Name");
if(strlen($company) < 1)
die("Please Click your Browser's Back button and Enter a Company");
if(strlen($address) < 1)
die("Please Click your Browser's Back button and Enter an Address");
if(strlen($city) < 1)
die("Please Click your Browser's Back button and Enter City, Zip, and State");
if(strlen($telephone) < 7)
die("Please Click your Browser's Back button and Enter a Telephone Number");
if(strlen($fax) < 7)
die("Please Click your Browser's Back button and Enter a Fax Number");
if(strlen($aoutdiam) < 1 and strlen($aindiam) < 1)
die("Please Click your Browser's Back button and Enter an Outside or Inside Diameter");
if(strlen($alengthmax) < 1 and strlen($blength) < 1)
die("Please Click your Browser's Back button and Enter a value for Length Inside Ends");
if(strlen($wirediam) < 1)
die("Please Click your Browser's Back button Enter a Wire Diameter");
if(strlen($type) < 1)
die("Please Click your Browser's Back button Enter Loop or Hook Type");
if(strlen($bodylength) < 1)
die("Please Click your Browser's Back button Enter Body Length");
if(strlen($initialtension) < 1)
die("Please Click your Browser's Back button Enter Initial Tension");
if(strlen($typematerial) < 1 and strlen($othertypematerial) < 1)
die("Please Click your Browser's Back button and Enter a value for Length Inside Ends");
// where to send it
// remove or configure one of the two code blocks
// otherwise your mail will be sent to johnnybegood@hotmail.com
//**** this one for the selectable recipients ****
$recips = array("support" => "support@somesite.com", "account" => "billing@somesite.com");
$recip = $recips[$recip];
// if something went wrong, send to default address
if(empty($recip)) $recip = "support@somesite.com";
// ***** end selectable recipient ********
// ***** or one fixed recipient ******
$recip = "spettye@houston.rr.com";
//**** end fixed recipient *******
// build up message
// this code for any multiline text fields
$message = str_replace("\r", "\n", $message);
// info vars
$sender = $_SERVER[REMOTE_ADDR];
// you can rearrange this - just do not add or remove quotes
$email_message = "RFQ Sent by
Name: $name
Title: $title
Company: $company
Address: $address
City, State, and Zip: $city
Telephone: $telephone
Fax: $fax
Email: $email
1. Outside Diameter
a. $aoutdiam $aoutdiaminch
b. $boutdiam $boutdiaminch +/- $boutdiamp $boutdiampinch
c. work in $coutdiam $coutdiaminch
2. Inside Diameter
a. $aindiam $aindiaminch
b. $bindiam $bindiaminch +/- $bindiamp $bindiampinch
c. work over $cindiam $cindiaminch
3. Load 1 $load1 $load1lbs +/- $load1p $load1plbs
@ $load1at $load1atlbs
Load 2 $load2 $load2lbs +/- $load2p $load2plbs
@ $load2at $load2atlbs
Rate: $rate $ratelbs +/- $ratep $rateplbs
between lengths of $ratebetween $ratebetweeninch and $ratebetweenand $ratebetweenandinch
4. Max. extended length (inside ends) without set: $maxextlength $maxextlengthinch
5. Relative loop position, $relativeloop degrees maximum, seperation of loop planes
6. Direction of wind: $dirwind
7. Loop or Hook type: $type
Advisory Data
1. Length inside ends:
a. $alengthmax $alengthmaxinch max., $alengthmin $alengthmininch min. or
b. $blength $blengthinch +/- $blengthp $blengthpinch
c. approx. $clength $clengthinch
2. Wire Diameter: $wirediam $wirediaminch
3. Mean Coil Diameter: $coildiam $coildiaminch
4. Number of Active Coils: $activecoils
5. Body Length: $bodylength $bodylengthinch
6. Initial Tension: $initialtension $initialtensionlbs
Special Information
1. Quanity to Quote: $quanityquote
2. Type of Material: $typematerial $othertypematerial
3. Finish: $finish
4. Operating Temperature: $operatingtemp $operatingtemptype
5. End Use or Application:
$enduse
6. Other:
$other
-------
Sender's IP Address: $sender";
//copy($file1, $file1_name);
$fileatt=$file1;
$fileatt_type=$file1_type;
$fileatt_name=$file1;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$headers = "From: RFQ@CoilingTech.com";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" ."--{$mime_boundary}--\n";
mail($recip, "RFQ", $email_message, $headers);
// send it off
// note - if you omit the last part, a few servers do not send mail at all,
// but most would show strange senders like nobody@server17.hostingcompany.com
//mail($recip, "RFQ for Extension Springs", $mailbody, "From: RFQ Form from Web Site");
// if($chked==0) unlink($file1_name);
// and tell visitor
print "Request for Quote has been sent! We will be contacting you shortly. Please Close this Window to Return to CoilingTech.com";
?>Email goes through like a champ but with no attachment... I get this error msg.
Code: Select all
Warning: fread(): supplied argument is not a valid stream resource in /home/httpd/vhosts/thecarsongroup.net/httpdocs/rfq2.php on line 141
Warning: fclose(): supplied argument is not a valid stream resource in /home/httpd/vhosts/thecarsongroup.net/httpdocs/rfq2.php on line 142
Request for Quote has been sent! We will be contacting you shortly. Please Close this Window to Return to CoilingTech.comfeyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]