I have a complete PHP code for my for but the attachment doesn't get sent with it when i try to use that function. Could someone please look at the script and tell me what I need to do to make it work...Everything else works right in the code but this part...
<?php
// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$Name = addslashes($_POST['Name']);
@$Email = addslashes($_POST['Email']);
@$Title = addslashes($_POST['Title']);
@$Company = addslashes($_POST['Company']);
@$Address = addslashes($_POST['Address']);
@$Address_2 = addslashes($_POST['Address_2']);
@$City = addslashes($_POST['City']);
@$State = addslashes($_POST['State']);
@$Zip = addslashes($_POST['Zip']);
@$Phone = addslashes($_POST['Phone']);
@$Fax = addslashes($_POST['Fax']);
@$textfield = addslashes($_POST['textfield']);
@$PCrefresh = addslashes($_POST['PCrefresh']);
@$years = addslashes($_POST['years']);
@$fileatt = $_FILES['file']['tmp_name'];
@$fileatt_type = $_FILES['file']['type'];
@$fileatt_name = $_FILES['file']['name'];
function validate_cardnum($cardnum)
{
$checkdigit=substr($cardnum,-1);
$remainingcardnum=substr($cardnum,0,strlen($cardnum)-1);
$i=0;
while($i < strlen($remainingcardnum))
{
if($i%2==0)
$remaing_array[$i]=substr($remainingcardnum,($i+1)*-1,1) * 2;
else
$remaing_array[$i]=substr($remainingcardnum,($i+1)*-1,1);
if($remaing_array[$i]>=10)
$checksum=$checksum+1;
@$checksum=$checksum+($remaing_array[$i]%10);
$i++;
}
@$calculatedcheckdigit=(10-($checksum%10))%10;
if( $calculatedcheckdigit==$checkdigit)
return true;
else
return false;
}
// Validation
if (strlen($Name) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Name) >25)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Name) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Email) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Title) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Title) >15)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Title) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Company) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Company) >25)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Company) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Address) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Address) >25)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Address) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($City) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($City) >15)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($City) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if ( strcasecmp($State,"AL") != 0 && strcasecmp($State,"AK") != 0 && strcasecmp($State,"AR") != 0 && strcasecmp($State,"AZ") != 0 && strcasecmp($State,"CA") != 0 && strcasecmp($State,"CO") != 0 && strcasecmp($State,"CT") != 0 && strcasecmp($State,"DC") != 0 && strcasecmp($State,"DE") != 0 && strcasecmp($State,"FL") != 0 && strcasecmp($State,"GA") != 0 && strcasecmp($State,"HI") != 0 && strcasecmp($State,"ID") != 0 && strcasecmp($State,"IL") != 0 && strcasecmp($State,"IN") != 0 && strcasecmp($State,"IA") != 0 && strcasecmp($State,"KS") != 0 && strcasecmp($State,"KY") != 0 && strcasecmp($State,"LA") != 0 && strcasecmp($State,"ME") != 0 && strcasecmp($State,"MD") != 0 && strcasecmp($State,"MA") != 0 && strcasecmp($State,"MI") != 0 && strcasecmp($State,"MN") != 0 && strcasecmp($State,"MS") != 0 && strcasecmp($State,"MO") != 0 && strcasecmp($State,"MT") != 0 && strcasecmp($State,"NE") != 0 && strcasecmp($State,"NV") != 0 && strcasecmp($State,"NH") != 0 && strcasecmp($State,"NJ") != 0 && strcasecmp($State,"NM") != 0 && strcasecmp($State,"NY") != 0 && strcasecmp($State,"NC") != 0 && strcasecmp($State,"ND") != 0 && strcasecmp($State,"OH") != 0 && strcasecmp($State,"OK") != 0 && strcasecmp($State,"OR") != 0 && strcasecmp($State,"PA") != 0 && strcasecmp($State,"RI") != 0 && strcasecmp($State,"SC") != 0 && strcasecmp($State,"SD") != 0 && strcasecmp($State,"TN") != 0 && strcasecmp($State,"TX") != 0 && strcasecmp($State,"UT") != 0 && strcasecmp($State,"VT") != 0 && strcasecmp($State,"VA") != 0 && strcasecmp($State,"WA") != 0 && strcasecmp($State,"WV") != 0 && strcasecmp($State,"WI") != 0 && strcasecmp($State,"WY") != 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($State) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Zip) != 5)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Zip) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Phone) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Phone) >12)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Phone) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Fax) <0)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Fax) >12)
{
header("Location: asset-error.htm");
exit;
}
if (strlen($Fax) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if ( $textfield < 0)
{
header("Location: asset-error.htm");
exit;
}
if ( $textfield > 100)
{
header("Location: asset-error.htm");
exit;
}
if ( strcasecmp($PCrefresh,"YES") != 0 && strcasecmp($PCrefresh,"NO") != 0 )
{
header("Location: asset-error.htm");
exit;
}
if (strlen($PCrefresh) == 0 )
{
header("Location: asset-error.htm");
exit;
}
if ( $years < 0)
{
header("Location: asset-error.htm");
exit;
}
if ( $years > 3)
{
header("Location: asset-error.htm");
exit;
}
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$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}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$data = chunk_split(base64_encode($data));
$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";
}
//Sending Email to form owner
$pfw_header = "From: $Email\n"
. "Reply-To: $Email\n";
$pfw_subject = "Asset Evaluation";
$pfw_email_to = "AYOB@LANTEKONLINE.COM";
$pfw_message = "Visitor's IP: $pfw_ip\r\n"
. "Name: $Name\r\n"
. "Email: $Email\r\n"
. "Title: $Title\r\n"
. "Company: $Company\r\n"
. "Address: $Address\r\n"
. "Address_2: $Address_2\r\n"
. "City: $City\r\n"
. "State: $State\r\n"
. "Zip: $Zip\r\n"
. "Phone: $Phone\r\n"
. "Fax: $Fax\r\n"
. "textfield: $textfield\r\n"
. "PCrefresh: $PCrefresh\r\n"
. "years: $years\r\n"
. "attachfile: $attachfile\r\n"
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: asset_thankyou.htm");
?>
Oh graet and now...
it gives this error
Parse error: parse error, unexpected '@' in C:\Inetpub\wwwroot\recovery disposal\rd\junk\index2.php on line 293
Darn PHP...