Jump to content

[SOLVED] Link to a Thankyou page from the end of an Email PHP script


scott56hannah

Recommended Posts

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

?>

Link to comment
Share on other sites

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 ?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.