hemjesti Posted August 20, 2010 Share Posted August 20, 2010 i am not a coder by any means and my boss threw me under the bus to add an auto reply to this form. I've figured out that this is the code that the form uses to process - but now i have NO IDEA what to do. Can ANYONE help me with this? it's supposed to have instructions in the response and send a copy to us and the the submitter. THANKS SO MUCH IN ADVANCE!!! Here's the php form code: <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 Hmm...for some strange reason that code is using HTML META Refresh to redirect the page instead of PHP header() functions. I wouldn't do that, but it will work. Anyway, it appears the script is already sending an email to the sales department. So, you need to send a copy to the submitter. You already have thier email address in the variable $Email. So, just add another line with the mail() function, but use their email instead of the $EmailTo (which goes to sales). You might also add some text to the top of the message stating something like "The following email was sent to...". Modify this // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } To this // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" + $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } To add instructions in the response you would need to modify the thank you page: contactthanks.php Quote Link to comment Share on other sites More sharing options...
sasa Posted August 20, 2010 Share Posted August 20, 2010 $message = "This is to confirm that the following message was sent to our sales department:\n\n" + $message; you mean dot not plus $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 awesome - so this i add the new:: // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" + $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } Does that mean that i now remove the info below this data - assuming i place it exactly where it is currently in the form code? REMOVE ??? ::: // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanksskins.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 i added the code you provided and i keep getting an error page??? totally lost here. Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 sort of freaking out here. i've broken the form! Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 As Sasa pointed out I erroneously used a plus (+) instead of a period (.) when creating the modified message. use this: // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } Also, if you get an error, by all means POST the error. Lastly, do not use your production environment for testing! Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 it's posting the error.htm page for some reason. I'm not sure if i am supposed to remove anything or just paste that other code in there? if i don't it looks like it's asking to 'print' two of the same page names? this is the error.htm copy - but i don't know how this is possible. the files are there. again, unless i'm pasting the code wrong. The page you tried to access does not exist on this server. This page may not exist due to the following reasons: 1. You are the owner of this web site and you have not uploaded (or incorrectly uploaded) your web site. For information on uploading your web site using FTP client software or web design software, click here for FTP Upload Information. 2. The URL that you have entered in your browser is incorrect. Please re-enter the URL and try again. 3. The Link that you clicked on incorrectly points to this page. Please contact the owner of this web site to inform them of this situation. Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 i'm looking at this stuff and the only thing i see that's dif is the first version has if success with else print - and the new copy has just if success ?? does that make a difference? or am i just being dumb? Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 20, 2010 Share Posted August 20, 2010 Post all of your code as it stands now. Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 This is the code currently after adding the provided code. I'm sorry I wish I knew how to code and I wouldn't be pestering anyone. <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; //$Body .= "City: "; //$Body .= $City; //$Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 20, 2010 Share Posted August 20, 2010 It looks like you overwrote the initial email sending: $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); You need to stick that line before the first if($success){ Line. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 You added the new code for the sucess condition instead of replaceing it. Try this: <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: {$Name}\n"; //$Body .= "City: {$City}\n"; $Body .= "Email: {$Email}\n"; $Body .= "Phone: {$Phone}\n"; $Body .= "Message: {$Message}\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success) { //Modify content for confirmation and send to user $message = "This is to confirm that the following message was sent to our sales department:\n\n" . $message; mail($Email, $Subject, $Body, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Edit: Also added the line to actually send the email that Nightslyr found. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 20, 2010 Share Posted August 20, 2010 <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = trim(stripslashes($_POST['Name'])); $Tel = trim(stripslashes($_POST['Tel'])); $Email = trim(stripslashes($_POST['Email'])); $Phone = trim(stripslashes($_POST['Phone'])); $Message = trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = "Name: $Name\n"; //$Body .= "City: $City\n"; $Body .= "Email: $Email\n"; $Body .= "Phone: $Phone\n"; $Body .= "Message: $Message\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success) { //Modify content for confirmation and send to user $Confirm = "This is to confirm that the following message was sent to our sales department:\n\n" . $Body; mail($Email, $Subject, $Confirm, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Here's a cleaned up version for you. Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 OMG!!! I LOOOOOOOOOVE YOU GUYS!!! I couldv'e never made that work on my own!!! I do have ONE more question - in the "From" in my inbox it says, "Win.One@p3nlhg150.shr.prod.phx3.secure" but in the code it says, "From" should be "Win One"? Any idea what that's about? How do I pay you guys? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 Try setting your FROM address to something like this $EmailFrom = "From: Win One <someaddress@yourcompany.com>"; Use a valid email address within the brackets for buncebacks and/or replies to be sent to. OMG!!! I LOOOOOOOOOVE YOU GUYS!!! Aw, shucks. Pls don't tell my wife. Quote Link to comment Share on other sites More sharing options...
jcbones Posted August 20, 2010 Share Posted August 20, 2010 Try setting your FROM address to something like this $EmailFrom = "From: Win One <someaddress@yourcompany.com>"; Use a valid email address within the brackets for buncebacks and/or replies to be sent to. Make sure it is a valid address, or some host will drop the email into the trash without sending it. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 OK, THAT'S IT! If I could I would delete every post I have made in this thread for I regret EVER having helped you. You are cheating on us with another forum! I caught you red handed: http://www.dynamicdrive.com/forums/showthread.php?p=235020 Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 20, 2010 Share Posted August 20, 2010 I feel so used... :'( Quote Link to comment Share on other sites More sharing options...
jcbones Posted August 20, 2010 Share Posted August 20, 2010 OK, THAT'S IT! If I could I would delete every post I have made in this thread for I regret EVER having helped you. You are cheating on us with another forum! I caught you red handed: http://www.dynamicdrive.com/forums/showthread.php?p=235020 And you were there for...? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 OK, THAT'S IT! If I could I would delete every post I have made in this thread for I regret EVER having helped you. You are cheating on us with another forum! I caught you red handed: http://www.dynamicdrive.com/forums/showthread.php?p=235020 And you were there for...? I was searching for the site in question using the email address used in the code, but capsonewire.com doesn't resolve to any website. When I googled that domain it hit on the post I linked to. I am faithfull to PHPFreaks (at least as far as you know I am). Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 Oh now, I was desperate! I was looking for any help at all!!! Watch my post at DD here in a second! Well, I'll do it now......... **jeopardy theme plays**.......... okay - this is what i wrote::: Thanks guys but I was helped by the phenom over at PHP Freaks. they were sooooo fast and helpful and didn't make me feel like the idiot i am when it comes to this stuff. Sorry for wasting your time. Hope I'm forgiven b/c i'm soooooooooooo greatful!! Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 Oh now, I was desperate! I wonder if my wife would buy that excuse if I cheated. Probably not worth finding out. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted August 20, 2010 Share Posted August 20, 2010 I am faithfull to PHPFreaks (at least as far as you know I am). That's where we differ. I'm a whore. Quote Link to comment Share on other sites More sharing options...
hemjesti Posted August 20, 2010 Author Share Posted August 20, 2010 I'll nar'post at DD again. I'm forever, a PHP Freak. You guys are going to have to roll with me and let me grow though! I'm not as smart as all you out there. My specialty is just breaking things. I'm sorry i cheated on my Freaks. 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.