Jump to content

Recommended Posts

Hi all

 

Not sure if this is the correct place for this!

 

I have a email autoresponder that works great, just how I want it, sends an email to the person who fills it in, sends us an email saying that someone has filled it in, and save details in a csv file.

 

What I would like to do, is add a function that sends a couple of files as an attachement (pdf) in the same email autoresponder that the visitors recieves. The files will be on the server.

 

Is there a piece of PHP code I can add that will basically specify the 2 files and send them in the same email. I don't want to send a link so they can download them.

 

The current .php file which does all the fancy stuff is:

 

<?php

 

// Receiving variables

@$name = addslashes($_POST['name']);

@$email = addslashes($_POST['email']);

@$country = addslashes($_POST['country']);

 

// Validation

if (strlen($name) <=1)

{

header("Location: error.php");

exit;

}

 

if (strlen($name) == 0 )

{

header("Location: error.php");

exit;

}

 

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))

{

header("Location: error.php");

exit;

}

 

if (strlen($email) == 0 )

{

header("Location: error.php");

exit;

}

 

if (strlen($country) == 0 )

{

header("Location: error.php");

exit;

}

 

//Sending Email to form owner

# Email to Owner

$pfw_header = "From: $email";

$pfw_subject = "-----------";

$pfw_email_to = "-----------";

$pfw_message = "$name \n"

. "\n"

. "-----------------------\n"

. "\n"

. "$email\n"

. "\n"

. "The visitor has come from\n"

. "\n"

. "$country\n";

@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

 

//Sending auto respond Email to user

# Email to Owner

$pfw_header = "From: ------------";

$pfw_subject = "--------------";

$pfw_email_to = "$email";

$pfw_message = "Dear $name\n"

. "\n"

. "---------------------------------------\n"

. "\n"

. "--------------- ($email)\n"

. "\n"

. "-------------------";

@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

 

//saving record in a text file

$pfw_file_name = "------------";

$pfw_first_raw = "name,email,country\r\n";

$pfw_values = "$name,$email,$country\r\n";

$pfw_is_first_row = false;

if(!file_exists($pfw_file_name))

{

$pfw_is_first_row = true ;

}

if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {

die("Cannot open file ($pfw_file_name)");

exit;

}

if ($pfw_is_first_row)

{

  if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {

  die("Cannot write to file ($pfw_filename)");

  exit;

  }

}

if (fwrite($pfw_handle, $pfw_values) === FALSE) {

  die("Cannot write to file ($pfw_filename)");

  exit;

}

fclose($pfw_handle);

 

header("Location: thankyou.php");

 

?>

 

Can anyone advise what the code should be and where to put it?

 

Many thanks & regards

 

 

Scot

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.