Sripped the code back trying to check whats going on where and all i know is i dont know jack :S
<?php
$sdTitle = $_POST['sdTitle'];
$sdName = $_POST['sdFname'];
$sdEmail = $_POST['sdEmail'];
$sdMoby = $_POST['sdMobile'];
$sdDayNum = $_POST['sdDayNum'];
$sdAdd1 = $_POST['sdAdd1'];
$sdPost = $_POST['sdPost'];
$sdDob = $_POST['sdDob'];
$sdOpt = $_POST['sdOpt'];
$sdQ1 = $_POST['sdQ1'];
$sdQ2 = $_POST['sdQ2'];
$sdQ3 = $_POST['sdQ3'];
$type = "application/vnd.ms-excel";
//$type = "application/x-msdownload";
$filepath = "temp/";
$file = $sdName."_.xls";
$bod = "Hi <br>Please find attached ".$file. " file.";
$subject = "Form submission";
$subject2 = "Submission received";
$compEmail = "noreply@company.com";
//----------------------------------//
function sendmsg($subject, $text, $from, $file, $type) {
$adminaddress = "paul@djdomain.com";
$content = fread(fopen($file,"r"),filesize($file));
$content = base64_encode($content);
$content = chunk_split($content);
$uid = strtoupper(md5(uniqid(time())));
$name = $file;
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$uid\n";
$header .= "--$uid\n";
$header .= "Content-Type: text/html\n";
$header .= "Content-Transfer-Encoding: 8bit\n\n";
$header .= "$text\n"; //Also text does not appear in email
$header .= "--$uid--\n\n"; //<THis line does not get added for some reason???
$header .= "Content-Type: $type; name=\"$name\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
$header .= "$content\n";
$header .= "--$uid--";
$ok = mail($adminaddress, $subject, "", $header);
if($ok){
//unlink('temp/'.$file);
echo "&retval=1&";
}
}
mail($sdEmail, $subject2, "Hi $sdName,
Your submission has been received.
Thanks,
","FROM:".$compEmail);
//----------------------------------//
// write xls file
$xls_file="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<head>
<meta http-equiv='Content-type' content='text/html;charset=iso-8859-1' /></head>
<body>
<div id='Classeur1_16681' align=center x:publishsource='Excel'>
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
<tr>
<td class=xl2216681 nowrap><b>Title</b></td>
<td class=xl2216681 nowrap><b>First Name</b></td>
<td class=xl2216681 nowrap><b>Address 1</b></td>
<td class=xl2216681 nowrap><b>Postcode</b></td>
<td class=xl2216681 nowrap><b>Mobile Number</b></td>
<td class=xl2216681 nowrap><b>Daytime Number</b></td>
<td class=xl2216681 nowrap><b>Email</b></td>
<td class=xl2216681 nowrap><b>d.o.b</b></td>
<td class=xl2216681 nowrap><b>Quesion 1</b></td>
<td class=xl2216681 nowrap><b>Quesion 2</b></td>
<td class=xl2216681 nowrap><b>Quesion 3</b></td>
<td class=xl2216681 nowrap><b>OPT IN?</b></td>
</tr>
<tr>
<td class=xl2216681 nowrap>$sdTitle</td>
<td class=xl2216681 nowrap>$sdName</td>
<td class=xl2216681 nowrap>$sdAdd1</td>
<td class=xl2216681 nowrap>$sdPost</td>
<td class=xl2216681 nowrap>$sdMoby</td>
<td class=xl2216681 nowrap>$sdDayNum</td>
<td class=xl2216681 nowrap>$sdEmail</td>
<td class=xl2216681 nowrap>$sdDob</td>
<td class=xl2216681 nowrap>$sdQ1</td>
<td class=xl2216681 nowrap>$sdQ2</td>
<td class=xl2216681 nowrap>$sdQ3</td>
<td class=xl2216681 nowrap>$sdOpt</td>
</tr>
</table>
</div>
</body>
</html>";
// If file does not exist create and make writeable
if (!file_exists($file)){
$handle = fopen($file, 'w+');
if (fwrite($handle, $xls_file) === FALSE){
echo '&phpError=Cannot write to file ('.$file.').&';
exit;
} else{
fclose($handle);
sendmsg($subject, $bod, $compEmail, $file,$type);
}
}
//
?>
Removed the save path and now the xls file is created in the same dir as the php script