craigtolputt Posted July 25, 2008 Share Posted July 25, 2008 Hi Guys, I have this php script that registers users and then sends them an email...... Does anyone know how to add a CC receipt to this?? <?php //include the connect script include "connect.php"; /*THIS VARIABLE IS WHAT TABLE YOU ARE USING...IF YOU USED MY SQL FILE, THEN YOUR DEFAULT TABLE*/ /*NAME SHOULD BE 'userv2' AND YOU DO NOT NEED TO CHANGE ANYTHING, BUT IF YOU MADE YOUR OWN TABLE,*/ /*CHANGE THIS VARIABLE.*/ $tableName = "DNAreg"; //Post all of the users information (md5 Encrypt the dna_no) $username = $_POST['username']; $dna_no = md5($_POST['dna_no']); $dna_no2 = ($_POST['dna_no']); $company = ($_POST['company']); $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $email = $_POST['email']; $phone = $_POST['phone']; $address = $_POST['address']; $city = $_POST['city']; $county = $_POST['county']; $postcode = $_POST['postcode']; $product = $_POST['product']; $can_loc = $_POST['can_loc']; $sender = $_POST['sender']; //Generate confKey (this is used to determine which user it is when the user forget's their dna_no. function createConfKey() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $key = ''; while ($i <= 31) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $key = $key . $tmp; $i++; } return $key; } $thekey = createConfKey(); //$theKey is the random 32 character string and then $confKey is the random 32 character string with md5 encryption. $confKey = md5($thekey); //grab all the usernames in the table $sql1 = mysql_query("SELECT * FROM $tableName WHERE dna_no = '$dna_no'"); //get number of results from both queries $row1 = mysql_num_rows($sql1); //if there is a result it will be either 1 or higher if($row1 > 0) { //echo username or email is already in use and deny registration. echo "&msgText=DNA Number already added!"; } else { //if there was no existing username or email, insert all their information into the database. $insert = mysql_query("INSERT INTO $tableName (username,dna_no,company,firstName,lastName,email,phone,address,city,county,postcode,product,can_loc,confKey) VALUES ('$username','$dna_no','$company','$firstName','$lastName','$email','$phone','$address','$city','$county','$postcode','$product','$can_loc','$confKey')") or die(mysql_error()); //This is required for and HTML email to be sent through PHP. $headers = "From: admin@redwebsecurity.com\r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; /******HERE YOU CAN EDIT WHAT YOU WANT THE EMAIL TO SAY WHEN THEY FORGET THEIR dna_no******/ /* */ /*PHP Explained: */ /*$msg are all the same variable, however, when you set the first one to just '=' and the */ /*second one to '.=' it basically concatinates the two variables. For example: */ /* */ /* */ /* $a = 1; */ /* $a .= 2; */ /* $a .= 3; */ /* echo $a; */ /* */ /* This will echo: 123 */ /* */ /* */ /* Be sure to include $firstName & $lastName somewhere in the message so the user knows */ /* what the message is */ /* */ /* */ /* */ /********************************************************************************************/ $msg = "Hello $username<br/><br/>"; $msg .= "We would like to thank you for registering your Product.<br/><br>"; $msg .= "Your dna_no is: $dna_no2<br/><br>"; $msg .= "Your Customers Details are:<br/><br>"; $msg .= "$company<br/>"; $msg .= "$firstName"; $msg .= "$lastName<br/>"; $msg .= "$address<br/>"; $msg .= "$city<br/>"; $msg .= "$county<br/>"; $msg .= "$postcode<br/><br>"; $msg .= "$phone<br/>"; $msg .= "<a href=\"mailto:$email\">$email</a><br/><br/>"; $msg .= "Your Registered Product is: $product<br/><br>"; $msg .= "Your Canister is located: $can_loc<br/><br>"; $msg .= "Please keep these safe and if you have any questions, contact us at <br><br>"; mail($sender,"Thanks for Registering!",$msg,$headers); //and echo "Successfully registered!" and take them to a "thanks for registering" frame in flash echo "&msgText=Successfully registered!"; echo "&nameText=$firstName"; } ?> I tried adding mail.("myemail@url.com","Thanks for Registering!",$msg,$headers); under this but it stopped the scriupt working mail($sender,"Thanks for Registering!",$msg,$headers); Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 25, 2008 Share Posted July 25, 2008 i think you need to add it to the headers found this on php.net $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 25, 2008 Author Share Posted July 25, 2008 cool ill add it in see if works Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 25, 2008 Author Share Posted July 25, 2008 That seemed to work but it adds it in the email header so im wondering if this will work for a blind carbon copy so that you cant see it in the header do you know how i would add that, perhaps something like... $headers .= 'BCc: birthdayarchive@example.com' . "\r\n"; ??? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted July 25, 2008 Share Posted July 25, 2008 that looks right the headers are sent to a server and not the actual recipient so they wont see the bcc but the header might be case sensitive so might need to be Bcc as on php.net Scott. Quote Link to comment Share on other sites More sharing options...
craigtolputt Posted July 25, 2008 Author Share Posted July 25, 2008 Sorted Thanks, Spot on works a treat mate 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.