Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: php email confirmation...

  1. #1
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php email confirmation...

    hello...

    i have a problem with this..
    can anyone tell me step by step how to email confirmation..like this forum..after i register, the confirmation email has been sent to my email address..and after that, they ask me to click the link so that my account will activated..please help me........

  2. #2
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    You can use the mail() function to send confirmation emails.

    All you need to do is set up a form and post the values to this php script

    e.g.

    PHP Code:
    //These are the variables for the email

    $sendto $_POST['email']; // this is the email address collected form the form
    $ccto "you@yourdomain.com"//you can cc it to yourself
    $subject "email confirmation"// Subject
    $message "the body of the email - this email is to confirm etc..."
    $header "From: auto-confirm@yourdomain.com\r\n";
    $header .= "Reply-to: you@yourdomain.com\r\n";
    // This is the function to send the email
    mail($sendto$subject$message$header); 
    This is only the basics, there's alot more to include in the script, like checking whether or not they've entered a valid email address etc. but this should give you a starting point.

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    part 2 of your question is more difficult.

    1) create an activated field in database (default to inactive)
    2) upon registration, the email is sent
    3) populate a link in the email, to include...
    a) user unique identifier
    b) activation to active
    so it would look something like this potentially
    [code]
    Welcome __username___. Thanks for registering, please click on the link below to activate your account
    domain.com/register.php?uid=100&activate=1

    4) is your registration script attempt to grab the user by the id
    5) update the activated field to true

    and there u have a new and active user.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    you'll want to generate a unique activation code for each user. You can use microtime() to get a random number, then run that through some hash algorithm, like md5().

    That will be an easy way to be sure they can't just figure out their confirmation.

    I'm sure you implied that, but good to be extra clear on that.

    I set up a similar system a bit ago. It wasn't that difficult, compared to other operations with php.


    I added a nice interface, though, by having a link that would automatically activate the account, and a backup.
    If they simply tried to log in, it would lock them out with a screen asking for the activation. They could then manually enter the code.
    It was easy, then, however they proceed from the registration phase.
    Additionally, I included a "cancel account" option on that validation page, if they decided they didn't want an account after all, so it was less work for the admin.

    Also, having a "resend validation email" is a good idea. The 'cancel account' option could be used for that, and it could also help if they didn't get the email because they supplied the wrong email address.
    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

  5. #5
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP email confirmation help

    Hey i saw this post online and its basically what im looking for but i was wondering if someone could help me with my php code.

    what i want it to do is take my form data and send the data to my email address send the person a confirmation email and redirect them to my homepage.

    here is the code i have now..

    right now i have it to where it will send the data to my email say thank you for submitting the form and redirects them to my home page using java script at the bottom.. can some one help me out.. thanks..


    PHP Code:
    <?php

    if(isset($_POST['submit'])) {

        
    $to "mscreativedesigns@gmail.com"
        
    $subject "Design Service Inquiry";
        
    $name_field $_POST['name'];
        
    $company_field $_POST['company'];
        
    $phone_field $_POST['phone'];
        
    $date_field $_POST['date'];
        
    $email_field $_POST['email'];
        
    $message_field $_POST['message'];
        
        
    $body "From: $name_field
        Company: 
    $company_field
        E-Mail: 
    $email_field
        Phone Number: 
    $phone_field
        Date: 
    $date_field
        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['email']; // this is the email address collected form the form
    $ccto "matt@mscreativedesigns.com"//you can cc it to yourself
    $subject "email confirmation"// Subject
    $message "the body of the email - this email is to confirm etc..."
    $header "From: [email]auto-confirm@mscreativedesigns.com[/email]\r\n";

    // This is the function to send the email
    mail($sendto$subject$message$header);  


    } else {
        echo 
    "An error has occured, please email [email]mscreativedesigns@gmail.com[/email] with your ";
    }

    ?>
    <script language=javascript>
    setTimeout("location.href='index.html'", [3000]);
    </script>
    Last edited by Snookerman; 01-07-2010 at 04:15 PM. Reason: please use [php] [/php] tags for php code

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    What exactly is NOT happening then? Email is sent to you, confirmation is displayed on the page, and the redirect works? Are they not getting the confirmation email?
    If $_POST['email'] is correctly set, I think that email would work.
    Note that $ccto is not actually being used anywhere, so that will not work. If you want it to, you can do this (after the line defining $ccto):
    $sendto = $sendto.', '.$ccto; //add the emails together

    There are some possibly better ways to approach a few of these things (for example, a non-javascript redirect), but in general it should be working.
    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. #7
    Join Date
    Mar 2010
    Location
    Washington, DC
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default php email parse error

    Hi

    I used SiteGrinder 2 Pro to set up this small website with a PHP registration form. SiteGrinder essentially set up the fields and all, but I had to hand code to do something more complex. On submit, the client wants the form to send the information to their (client's) email, and send an email ("thank you for registering, you entered the following information...") to the sender as well, AND be re-directed to another page on the site. I'm getting a parsing error, which makes sense because I know next to squat about php.

    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";
      
        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 language=javascript>
    setTimeout("location.href='index.html'", [3000]);
    </script>
    The error states:
    Parse error: syntax error, unexpected T_VARIABLE in /home_contact.php on line 50
    Line 50 refers to the "$header = "From: my@email.com\r\n";" line.

    Thanks for any assistance and try not to laugh too hard at my screw ups.

  8. #8
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Line 45 needs a semicolon
    PHP Code:
    $message "Thank you for registering with..." 
    should be

    PHP Code:
    $message "Thank you for registering with..."
    Corrections to my coding/thoughts welcome.

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

    Default

    Now I'm getting a parsing error on line 52:
    Parse error: syntax error, unexpected '=' in /home_contact.php on line 52
    Line 52 is the
    Code:
    location.href='attendee.html';
    line

    Thanks!

  10. #10
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Can you post the code you have the line you've stated isn't in the php you've posted above so that wouldn't be the error.
    Corrections to my coding/thoughts welcome.

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
  •