Solved

process-form.php - need autoreply and cc

Posted on 2010-09-23
7
867 Views
Last Modified: 2012-05-10
Looking for a way to add a Cc to this code as well as an autoreply
<?php
// Mail header removal
function remove_headers($string) { 
  $headers = array(
    "/to\:/i",
    "/from\:/i",
    "/bcc\:/i",
    "/cc\:/i",
    "/Content\-Transfer\-Encoding\:/i",
    "/Content\-Type\:/i",
    "/Mime\-Version\:/i" 
  ); 
  return preg_replace($headers, '', $string); 
}
// Pick up the form data and assign it to variables
$LAST_NAME = $_POST['LAST_NAME'];
$FIRST_NAME = $_POST['FIRST_NAME'];
$STREET_ADDRESS = $_POST['STREET_ADDRESS'];
$APARTMENT_NO = $_POST['APARTMENT_NO'];
$email = $_POST['email'];
$CITY = $_POST['CITY'];
$email = $_POST['email'];
$STATE = $_POST['STATE'];
$ZIP = $_POST['ZIP'];
$PHONE = $_POST['PHONE'];
$DEGREE = $_POST['DEGREE'];
$SPECIALTY = $_POST['SPECIALTY'];
$Type_of_Registration = $_POST['Type_of_Registration'];
$CC = $_POST['CC'];
$NAME_ON_CREDIT_CARD = $_POST['NAME_ON_CREDIT_CARD'];
$CREDIT_CARD_NO = $_POST['CREDIT_CARD_NO'];
$EXP_DATE_MONTH = $_POST['EXP_DATE_MONTH'];
$EXP_DATE_YEAR = $_POST['EXP_DATE_YEAR'];
$Surname = $_POST['Surname'];
$autoreply = "Thank you for registering online for the Therapeutic ERCP/EUS Workshop. \n\nConference date: Thursday, October 28, 2010\n\nConference times: 7:30 a.m. until 4:30 p.m. \n\n(Continental breakfast begins at 7:30 a.m. Lunch is at 12:00 p.m.)\n\nFor more information or to register please call (909) 920-5877 ext. 21";





// Build the email (replace the address in the $to section with your own)
$to = 'me@mydomain.com';
$subject = "Online Registration - Therapeutic ERCP/EUS Workshop";
$headers .= "From: $email \n\n";
$message .= "Name: $FIRST_NAME $LAST_NAME \n\n";
$message .=  "Address: $STREET_ADDRESS \n\n";
$message .=  "Address2: $APARTMENT_NO \n\n";
$message .=  "City: $CITY  \n\n";
$message .=  "State: $STATE \n\n";
$message .=  "Zip: $ZIP \n\n";
$message .= "Phone: $PHONE \n\n";
$message .= "Email: $email \n\n";
$message .=  "Degree: $DEGREE \n\n";
$message .=  "Specialty: $SPECIALTY \n\n";
$message .=  "Registration Type: $Type_of_Registration \n\n";
$message .=  "Credit Card Type: $CC \n\n";
$message .=  "Name on Card: $NAME_ON_CREDIT_CARD \n\n";
$message .=  "Credit Card Number: $CREDIT_CARD_NO \n\n";
$message .=  "Credit Card Expiration Date: $EXP_DATE_MONTH, $EXP_DATE_YEAR \n\n";

 $Comments = $_POST['Surname']; 
if ($Comments != '') { 
exit("Thanks for your input Spammy"); 
} else {

// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

// Redirect
header("Location: https://bla.org/classes/thanks_cme3.html"); 
}
?>

Open in new window

0
Comment
Question by:phillystyle123
  • 4
  • 3
7 Comments
 
LVL 32

Assisted Solution

by:DrDamnit
DrDamnit earned 200 total points
ID: 33750566
1. It is irresponsible to send credit card information via email unless your email server is employing TLS/SSL. I am assuming you are encrypting this traffic at all points from user entry on the original page, the page where you're posting this, end to end encryption with SSL/TLS when it is being sent to the server, drive encryption to prevent the credit cards from being stolen off the disk or accidental exposure, and then again between the server and the recipients of your to, cc, and other fields.

if not, you need to re-think your strategy about taking cards online. I suggest using authorize.net or some other gateway that has a secure API with which you can use PHP to write code for.

To answer your question:

Just add it to the headers:
$headers .= "BCC: dumidesign@gmail.com\n\n";
$headers .= "CC: somewhereelse@gmail.com\n\n";

I personally recommend that you use phpmailer, which is a class that takes care of all the messy work for you:

http://phpmailer.worxware.com/
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 33750576
Oh... and for the autoreply, just create a second message after you send the first with your autoreply message in it: "Your card has been processed. Thanks." or something like that.
0
 

Author Comment

by:phillystyle123
ID: 33750622
thanks for the help DrDamnit (best username ever). We've been trying to get them to do this the right way for years - to no avail.

I completely get the CC, Bcc stuff but am a little fuzzy on the autoreply.

now do i create a 2nd message after i send my first message?  can you provide an example?

Thanks
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:phillystyle123
ID: 33750857
Prior to trying to test the autoreply, I added DrDamnit's code for the cc and i did not recieve a cc. then I added code for the autoreply and that's not working either.  I need to be steered in the right direction please.
// Build the email (replace the address in the $to section with your own)
$to = 'bla@hmydomain.com';
$subject = "Online Registration - Therapeutic ERCP/EUS Workshop";
$headers .= "From: $email \n\n";
$headers .= "CC: craigmusicelkins@gmail.com\n\n";
$message .= "Name: $FIRST_NAME $LAST_NAME \n\n";
$message .=  "Address: $STREET_ADDRESS \n\n";
$message .=  "Address2: $APARTMENT_NO \n\n";
$message .=  "City: $CITY  \n\n";
$message .=  "State: $STATE \n\n";
$message .=  "Zip: $ZIP \n\n";
$message .= "Phone: $PHONE \n\n";
$message .= "Email: $email \n\n";
$message .=  "Degree: $DEGREE \n\n";
$message .=  "Specialty: $SPECIALTY \n\n";
$message .=  "Registration Type: $Type_of_Registration \n\n";
$message .=  "Credit Card Type: $CC \n\n";
$message .=  "Name on Card: $NAME_ON_CREDIT_CARD \n\n";
$message .=  "Credit Card Number: $CREDIT_CARD_NO \n\n";
$message .=  "Credit Card Expiration Date: $EXP_DATE_MONTH, $EXP_DATE_YEAR \n\n";


 $Comments = $_POST['Surname']; 
if ($Comments != '') { 
exit("Thanks for your input Spammy"); 
} else {

// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

//auto reply
$to2 = '$email';
$subject2 = "Therapeutic ERCP/EUS Workshop Online Registration Confirmation";
$headers2 .= "From: celkins@healthpresence.com\n\n";
$message2 .= "Thank you for registering online for the Therapeutic ERCP/EUS Workshop. \n\nConference date: Thursday, October 28, 2010\n\nConference times: 7:30 a.m. until 4:30 p.m. \n\n(Continental breakfast begins at 7:30 a.m. Lunch is at 12:00 p.m.)\n\nFor more information or to register please call (909) 920-5877 ext. 21 \n\n";

// Send the mail using PHPs mail() function
mail($to2, $subject2, $message2, $headers2);

Open in new window

0
 

Accepted Solution

by:
phillystyle123 earned 0 total points
ID: 33756138
Final answer! The following process-form.php incorporates Cc and autoreply.
<?php
// Mail header removal
function remove_headers($string) { 
  $headers = array(
    "/to\:/i",
    "/from\:/i",
    "/bcc\:/i",
    "/cc\:/i",
    "/Content\-Transfer\-Encoding\:/i",
    "/Content\-Type\:/i",
    "/Mime\-Version\:/i" 
  ); 
  return preg_replace($headers, '', $string); 
}
// Pick up the form data and assign it to variables
$LAST_NAME = $_POST['LAST_NAME'];
$FIRST_NAME = $_POST['FIRST_NAME'];
$STREET_ADDRESS = $_POST['STREET_ADDRESS'];
$APARTMENT_NO = $_POST['APARTMENT_NO'];
$email = $_POST['email'];
$CITY = $_POST['CITY'];
$email = $_POST['email'];
$STATE = $_POST['STATE'];
$ZIP = $_POST['ZIP'];
$PHONE = $_POST['PHONE'];
$DEGREE = $_POST['DEGREE'];
$SPECIALTY = $_POST['SPECIALTY'];
$Type_of_Registration = $_POST['Type_of_Registration'];
$CC = $_POST['CC'];
$NAME_ON_CREDIT_CARD = $_POST['NAME_ON_CREDIT_CARD'];
$CREDIT_CARD_NO = $_POST['CREDIT_CARD_NO'];
$EXP_DATE_MONTH = $_POST['EXP_DATE_MONTH'];
$EXP_DATE_YEAR = $_POST['EXP_DATE_YEAR'];
$Surname = $_POST['Surname'];
$ccaddress = "craigmusicelkins@gmail.com";


// Build the email (replace the address in the $to section with your own)
$to = 'myemail@domain.com';
$subject = "Online Registration - Therapeutic ERCP/EUS Workshop";
$headers .= "From: $email \r\n";
$headers .= "CC: $ccaddress \r\n";
$message .= "Name: $FIRST_NAME $LAST_NAME \r\n";
$message .=  "Address: $STREET_ADDRESS \r\n";
$message .=  "Address2: $APARTMENT_NO \r\n";
$message .=  "City: $CITY  \r\n";
$message .=  "State: $STATE \r\n";
$message .=  "Zip: $ZIP \r\n";
$message .= "Phone: $PHONE \r\n";
$message .= "Email: $email \r\n";
$message .=  "Degree: $DEGREE \r\n";
$message .=  "Specialty: $SPECIALTY \r\n";
$message .=  "Registration Type: $Type_of_Registration \r\n";
$message .=  "Credit Card Type: $CC \r\n";
$message .=  "Name on Card: $NAME_ON_CREDIT_CARD \r\n";
$message .=  "Credit Card Number: $CREDIT_CARD_NO \r\n";
$message .=  "Credit Card Expiration Date: $EXP_DATE_MONTH, $EXP_DATE_YEAR \r\n";
$autoTo = "$email \r\n";
$autoreply = "Thank you for registering for the Therapeutic ERCP/EUS Workshop\r\n\r\nCourse Info:\r\n\r\nThursday, October 28, 2010\r\n7:30 a.m. until 4:30 p.m.\r\n(Registration & continental breakfast begins at 7:30 a.m. Lunch is at 12:00 p.m.)\r\n\r\nFor further assistance, please call (909) 920-5877 ext. 21."; //change this to your message


 $Comments = $_POST['Surname']; 
if ($Comments != '') { 
exit("Thanks for your input Spammy"); 
} else {

// Send the mail using PHPs mail() function




mail($to, $subject, $message, $headers);
mail($autoTo, "Thank you for registering for the Therapeutic ERCP/EUS Workshop", $autoreply, 'From: noreply@domain.com');







// Redirect
header("Location: https://mydomain.org/classes/thanks_cme3.html"); 
}
?>

Open in new window

0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 33758341
Good job. I have been out of the office all day or would have seen you question and my typeo (\n\n should have been \r\n).
0
 

Author Comment

by:phillystyle123
ID: 33758700
thanks & thanks for the help
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hasing a url 16 24
ignore other .htaccess 2 44
What does $selected = $month == $beginning_month ? 'selected' : ''; mean? 5 26
Is there a simpler dropbox system? 10 18
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question