Jump to content

Girl in trouble


hemjesti

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 $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;

Link to comment
Share on other sites

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

}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

}

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

OMG!!!  :o 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?

Link to comment
Share on other sites

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!!!  :o I LOOOOOOOOOVE YOU GUYS!!!

 

Aw, shucks. Pls don't tell my wife.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...?  :o

 

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).

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

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.

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.