scott56hannah Posted December 18, 2007 Share Posted December 18, 2007 Hi, I now have a PHP script that will send an attachment from my website. At the end of the PHP script I want to direct the success when mailing to a Thankyou page that is formatted like the rest of my website....I cannot use the Headers() function as this has already been set in Mail() function...I have included the code below that is resulting in the error that I need to resolve....Any help appreciated... <?php $FirstName = $_POST['FirstName']; #assign value $LastName = $_POST['LastName']; #assign value $Address = $_POST['Address']; #assign value $Country = $_POST['Country']; #assign value $Mobile = $_POST['Mobile']; #assign value $Phone = $_POST['Phone']; #assign value $Email = $_POST['Email']; #assign value $Message = $_POST['Message']; #assign value $To = "sales@domain.com.au"; #recipient $Subject = "Contact Us Form Feedback from ".$Email; #subject #create the comments that will be sent as text in the message later on $Comments = "First Name :".$FirstName."\n"; $Comments .= "Last Name :".$LastName."\n"; $Comments .= "Address :".$Address."\n"; $Comments .= "Country :".$Country."\n"; $Comments .= "Mobile :".$Mobile."\n"; $Comments .= "Phone :".$Phone."\n"; $Comments .= "Email :".$Email."\n"; $Comments .= "Message :".$Message."\n"; $Attachment = $_FILES['ClientFile']; $FilePath = $_FILES['ClientFile']['tmp_name']; $FileName = $_FILES['ClientFile']['name']; $FileSize = $_FILES['ClientFile']['size']; $FileType = $_FILES['ClientFile']['type']; $FileError = $_FILES['ClientFile']['error']; #echo "FilePath ".$FilePath."\n"; #echo "FileName ".$FileName."\n"; #echo "FileSize ".$FileSize."\n"; #echo "FileType ".$FileType."\n"; #echo "FileError ".$FileError."\n"; #create a bounday string $num = md5(time()); $bound_text = "Multipart_Boundary_x{$num}x"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; #set the header information before including the text and file details $headers = "From: website@domain.com.au\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$bound_text\""; #now include the text of the message before including the file $msg = "If you can see this MIME than your client doesn't accept MIME types!\r\n"; $msg .= $bound; $msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" .$Comments."\r\n\n" .$bound; #now set the file name for the function to return the file for sending $file = file_get_contents($FilePath); #now add the file to the message contents for sending $msg .= "Content-Type: {$FileType}; name=\"{$FileName}\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"{$FileName}\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; #now ready to send the email if(mail($To, $Subject, $msg, $headers)) { echo "Need to develop a way to go to the Thankyou page"; headers("Location: Thankyou.html"); } else { echo "Mail Failed"; } ?> Quote Link to comment Share on other sites More sharing options...
papaface Posted December 18, 2007 Share Posted December 18, 2007 Javascript? <script language="JavaScript"> window.location="http://www.yourdomain.com/"; </script> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 18, 2007 Share Posted December 18, 2007 this echo "Need to develop a way to go to the Thankyou page"; headers("Location: Thankyou.html"); should only be headers("Location: Thankyou.html"); Quote Link to comment Share on other sites More sharing options...
scott56hannah Posted December 18, 2007 Author Share Posted December 18, 2007 Included the Javascript suggestion as below #now ready to send the email if(mail($To, $Subject, $msg, $headers)) { echo "<script language="JavaScript">window.location="http://www.mydomain.com.au/Thankyou.html";</script>"; } else { echo "Mail Failed"; } I am getting the following error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /clientdata/clients/i/n/mydomain.com.au/www/testing/Thanks.php on line 70 How should the Javascript be included to the PHP echo statement ? Quote Link to comment Share on other sites More sharing options...
papaface Posted December 18, 2007 Share Posted December 18, 2007 Doing what rajivgonsalves suggested will fix the original issue. Quote Link to comment Share on other sites More sharing options...
scott56hannah Posted December 18, 2007 Author Share Posted December 18, 2007 I had already tried that.....tried it again and it has resolved my problems Thanks for your help 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.