Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: php email confirmation...

  1. #11
    Join Date
    Mar 2010
    Location
    Washington, DC
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Oops! New Code

    Sorry about that Blue. Here is the code:
    Code:
    <?php
    
       
     if(($_POST['college']=="")||($_POST['streetaddress']=="")||($_POST['city']=="")||($_POST['zip']=="")||($_POST['state']=="")||($_POST['contactperson']=="")||($_POST['contactemail']=="")||($_POST['phone']=="")||($_POST['fax']==""))
     {
      echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>";
      if($_POST['college'] == ""){ echo "<li>*College</li>"; }
      if($_POST['streetaddress'] == ""){ echo "<li>*Street Address</li>"; }
      if($_POST['city'] == ""){ echo "<li>*City</li>"; }
      if($_POST['zip'] == ""){ echo "<li>*Zip</li>"; }
      if($_POST['state'] == ""){ echo "<li>*State</li>"; }
      if($_POST['contactperson'] == ""){ echo "<li>*Contact Person</li>"; }
      if($_POST['contactemail'] == ""){ echo "<li>*Contact Email</li>"; }
      if($_POST['phone'] == ""){ echo "<li>*Phone</li>"; }
      echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back</a> button and fill out these fields.</p></body></html>";
     }
     
     if(isset($_POST['submit'])) {
    
        $to = "my@email.com"; 
        $subject = "Contact Has Registered";
        $college = $_POST['college'];
        $streetaddress = $_POST['streetaddress'];
        $city = $_POST['city'];
        $state = $_POST['date'];
        $contactperson = $_POST['contactperson'];
        $contactemail = $_POST['contactemail'];
    	$phone = $_POST['phone'];
        
        $body = "From: $college
        Street Address: $streetaddress
        E-Mail: $contactemail
        Phone Number: $phone
        Contact Email: $contactemail
        Message: $message_field";
    
        echo "We've recived your contact information $to! We will be in Contact with you shortly!" ;
        
        mail($to, $subject, $body); 
        
    //These are the variables for the email
    
    $sendto = $_POST['contactemail']; // this is the email address collected form the form
    $ccto = "my@email.com"; //you can cc it to yourself
    $subject = "Registration"; // Subject
    $message = "Thank you for registering with...";
    $header = "From: my@email.com\r\n";
    
    Location.href="attendee.html";
    
    // This is the function to send the email
    mail($sendto, $subject, $message, $header);  
    
    
    } 
    
    ?>
    <script type=text/javascript>
    setTimeout("location.href='index.html'", [3000]);
    </script>

  2. #12
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Umm....
    PHP Code:
    location.href='attendee.html'
    That would be javascript.
    Try this:
    PHP Code:
    header("location: attendee.html"); 
    EDIT: Put that after you use mail(); and You may want to use conditonals on the mail like: if(mail(...))header("location: attendee.html"); else echo "Error, please try again";
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. The Following User Says Thank You to fileserverdirect For This Useful Post:

    kairick (06-09-2010)

  4. #13
    Join Date
    Mar 2010
    Location
    Washington, DC
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks so much for your help.

    The email is generating fine, but I would like to be able to include the information the user enters into the form in the email for their records. How would I do that?

    Code:
    <?php
    
       
     if(($_POST['college']=="")||($_POST['streetaddress']=="")||($_POST['city']=="")||($_POST['zip']=="")||($_POST['state']=="")||($_POST['contactperson']=="")||($_POST['contactemail']=="")||($_POST['phone']=="")||($_POST['fax']==""))
     {
      echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>";
      if($_POST['college'] == ""){ echo "<li>*College</li>"; }
      if($_POST['streetaddress'] == ""){ echo "<li>*Street Address</li>"; }
      if($_POST['city'] == ""){ echo "<li>*City</li>"; }
      if($_POST['zip'] == ""){ echo "<li>*Zip</li>"; }
      if($_POST['state'] == ""){ echo "<li>*State</li>"; }
      if($_POST['contactperson'] == ""){ echo "<li>*Contact Person</li>"; }
      if($_POST['contactemail'] == ""){ echo "<li>*Contact Email</li>"; }
      if($_POST['phone'] == ""){ echo "<li>*Phone</li>"; }
      echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back</a> button and fill out these fields.</p></body></html>";
     }
     
     if(isset($_POST['submit'])) {
    
        $to = "my@email.com"; 
        $subject = "Contact Has Registered";
        $college = $_POST['college'];
        $streetaddress = $_POST['streetaddress'];
        $city = $_POST['city'];
        $state = $_POST['date'];
        $contactperson = $_POST['contactperson'];
        $contactemail = $_POST['contactemail'];
    	$phone = $_POST['phone'];
        
        $body = "From: $college
        Street Address: $streetaddress
        E-Mail: $contactemail
        Phone Number: $phone
        Contact Email: $contactemail
        Message: $message_field";
    
        echo "We've recived your contact information $to! We will be in Contact with you shortly!" ;
        
        mail($to, $subject, $body); 
        
    //These are the variables for the email
    
    $sendto = $_POST['contactemail']; // this is the email address collected form the form
    $ccto = "my@email.com"; //you can cc it to yourself
    $subject = "Registration"; // Subject
    $message = "Thank you for registering with...";
    $header = "From: my@email.com\r\n";
    
    // This is the function to send the email
    if(mail($sendto, $subject, $message, $header)) header("location: attendee.html"); 
    } 
    
    ?>
    <script type=text/javascript>
    setTimeout("location.href='index.html'", [3000]);
    </script>
    Last edited by kairick; 06-09-2010 at 09:10 PM. Reason: RESOLVED

  5. #14
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    I've noticed that your script is very messy, some variables are being set and not used, $ccto and your using $_POST['contactemail'];
    when its already set to $contactemail
    To send the user their entered info, just paste this in (red):
    Code:
    if(mail($sendto, $subject, $body, $header)) header("location: attendee.html"); 
    }
    You may also want to add an else statement to EACH of the mail(); functions. If you need help, just ask.
    Last edited by fileserverdirect; 06-10-2010 at 07:19 PM. Reason: If I change it to [CODE] it works.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  6. #15
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    fsd, I don't believe [color] tags work within [php] blocks. I tried to fix your post (edited it) but it didn't change.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #16
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hello
    thank you for sharing code and i get good information for your side.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •