SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Enthusiast dannbkk's Avatar
    Join Date
    Jan 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Email & Database submission

    Once this form is submitted the info goes to database, but for some reason its im not getting a copy to my email which i should be, im not understanding why? what code will i need to add or modify to get a copy to my email account...

    PHP Code:
    <?php
    require_once('db.inc.php');
    if (isset(
    $_POST['sell_submit'])) {
        if (
    $_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
          echo 
    'Please hit the back button and fill up the 2 fields.';
          exit();
        } elseif (!
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$_POST['email'])) {
            echo 
    'Email not valid.';
            exit();
          } else {
            
    $to 'info@email.com';
            
    $eol "\r\n";
            
    $subject 'WEBSITE (Sell Business)';
            
    $headers .= 'From: Website Business<info@email.com>'.$eol;
            
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
            
    $headers .= 'MIME-Version: 1.0 '.$eol;
            
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
            
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
            
    $body 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
            
    $body .= 'Email: '.$_POST['email'].'<br>';
            
    $body .= 'Business Type: '.$_POST['biz_type'].'<br>';
            
    $body .= 'Warm Regards,<br><br>';
            
    $body .= 'WEBSITE<br>';
            
    $body .= 'www.website.com<br>';
            
    $body .= 'www.website.com';
            
    mail($to$subject$body$headers);
            }
    ?>
    Last edited by dannbkk; Jun 11, 2007 at 01:34.
    Learn SEO - Join the community at GSEO.net
    SEO Book - SEO Revenge eBook
    Make Money Programs - No Fluff!
    Make Money Online

  2. #2
    SitePoint Zealot Servyces's Avatar
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You forgot one } at the end to close the
    Code php:
    if (isset($_POST['sell_submit'])) {
    check.
    Last edited by Servyces; Jun 13, 2007 at 10:44.
    Servyces.com
    Where itís all about you.
    Your partner in online solutions.
    Visit our website at http://www.servyces.com/

  3. #3
    SitePoint Enthusiast dannbkk's Avatar
    Join Date
    Jan 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what do you mean? it appears i have closed it.
    Learn SEO - Join the community at GSEO.net
    SEO Book - SEO Revenge eBook
    Make Money Programs - No Fluff!
    Make Money Online

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dannbkk View Post
    what do you mean? it appears i have closed it.
    It'd be easier to see if you indent blocks in your code and use [php] tags when you post it on the forum

  5. #5
    SitePoint Zealot Servyces's Avatar
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dannbkk View Post
    what do you mean? it appears i have closed it.
    Brackets are deceivable things And using indent as stated can indeed help you spot this. See the example below.

    PHP Code:
    <?php
    require_once('db.inc.php');
    if (isset(
    $_POST['sell_submit'])) {
        if (
    $_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
            echo 
    'Please hit the back button and fill up the 2 fields.';
            exit();
        } elseif (!
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$_POST['email'])) {
            echo 
    'Email not valid.';
            exit();
        } else {
            
    $to 'info@email.com';
            
    $eol "\r\n";
            
    $subject 'WEBSITE (Sell Business)';
            
    $headers .= 'From: Website Business<info@email.com>'.$eol;
            
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
            
    $headers .= 'MIME-Version: 1.0 '.$eol;
            
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
            
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
            
    $body 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
            
    $body .= 'Email: '.$_POST['email'].'<br>';
            
    $body .= 'Business Type: '.$_POST['biz_type'].'<br>';
            
    $body .= 'Warm Regards,<br><br>';
            
    $body .= 'WEBSITE<br>';
            
    $body .= 'www.website.com<br>';
            
    $body .= 'www.website.com';
            
    mail($to$subject$body$headers);
        } 
    // <--- Your script ended here
    // <--- Add this one to close everything.
    ?>
    Notice how the last closing bracket from your code is still indented? That's because it's not the last bracket that the script should have. So add another closing bracket under there that's not indented and everything should work fine.
    Last edited by Servyces; Jun 13, 2007 at 10:31.
    Servyces.com
    Where itís all about you.
    Your partner in online solutions.
    Visit our website at http://www.servyces.com/

  6. #6
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, you need another bracket at the end of the script.

  7. #7
    SitePoint Enthusiast dannbkk's Avatar
    Join Date
    Jan 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have added the extra quote but its still not doing what i want it to...

    As i say i want to be able to have a copy of the information they submit to my email aswell. At the moment its only submitting to the database?
    Learn SEO - Join the community at GSEO.net
    SEO Book - SEO Revenge eBook
    Make Money Programs - No Fluff!
    Make Money Online

  8. #8
    SitePoint Zealot Servyces's Avatar
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I am spotting the problem. You are only appending the $headers, you do never initialize it. Also, I added a debug part so you can see if the server actually mails anything (or at least tries to). See the comments below

    PHP Code:
    <?php
    require_once('db.inc.php');
    if (isset(
    $_POST['sell_submit'])) {
        if (
    $_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
            echo 
    'Please hit the back button and fill up the 2 fields.';
            exit();
        } elseif (!
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$_POST['email'])) {
            echo 
    'Email not valid.';
            exit();
        } else {
            
    $to 'info@email.com';
            
    $eol "\r\n";
            
    $subject 'WEBSITE (Sell Business)';
            
    $headers 'From: Website Business<info@email.com>'.$eol// <--- Start here with $headers = and not with $headers .= !
            
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
            
    $headers .= 'MIME-Version: 1.0 '.$eol;
            
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
            
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
            
    $body 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
            
    $body .= 'Email: '.$_POST['email'].'<br>';
            
    $body .= 'Business Type: '.$_POST['biz_type'].'<br>';
            
    $body .= 'Warm Regards,<br><br>';
            
    $body .= 'WEBSITE<br>';
            
    $body .= 'www.website.com<br>';
            
    $body .= 'www.website.com';
            
    $mail_it mail($to$subject$body$headers); // <--- Mind the $mail_it = here !
        
    }
    }
    // Add this code to check if the mail function was executed.
    if(!$mail_it) {
        echo 
    'Oops, something went wrong.';
    } else {
        echo 
    'Mail sent.';
    }
    ?>
    If the mail is not sent, something is most likely to be wrong with your if/else statement.
    Last edited by Servyces; Jun 13, 2007 at 10:30.
    Servyces.com
    Where itís all about you.
    Your partner in online solutions.
    Visit our website at http://www.servyces.com/

  9. #9
    SitePoint Enthusiast dannbkk's Avatar
    Join Date
    Jan 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me allaborate, I am getting the email but i am getting the wrong information to my email when i submit on the form i am getting this info ;

    $body = 'Dear '.$name.',<br><br>';
    $body .= 'Thankyou for submitting your interest in business for sale at Elite Property Group.<br>';
    $body .= 'We have captured your details for the business you are interested in and will be contacting you shortly.

    when i should be getting the info that has been submitted such as;
    userid, name, email, phone, enquiry, reference, status) VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";

    hope that makes sense and you can help me out?



    It came up with the error, oops, something went wrong'

    actually this was the form and code i needed it on;

    PHP Code:
    <?php
    require_once('db.inc.php');
    if (isset(
    $_POST['submit'])) {
        
    $name $_POST['name'];
        
    $email $_POST['email'];
        
    $phone ereg_replace("[^0-9+ ]"""$_POST['phone']);
        
    $enquiry ereg_replace("\n""<br>"$_POST['enquiry']);
        
    $reference $_POST['reference'];
        echo 
    $biz_id;
        if (empty(
    $name) || empty($email) || empty($phone) || empty($enquiry)) {
            echo 
    'Please fill up all the forms.';
        } elseif (!
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$email)) {
            echo 
    'Email is not validate.';
          } else {
                
    $query "INSERT INTO mailing_list (userid, name, email, phone, enquiry, reference, status) VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
                
    mysql_query($query) or die("MySQL Error :" mysql_error());
                
    $eol "\r\n";
                
    $title 'BUSINESS GROUP (Enquiry)';
                
    $email 'info@email.com';
                
    $headers 'From: Business Groups<info@anotheremail.com>'.$eol;
                
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
                
    $headers .= 'MIME-Version: 1.0 '.$eol;
                
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
                
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
                
    $body 'Dear '.$name.',<br><br>';
                
    $body .= 'Thankyou for submitting your interest in business for sale at Elite Property Group.<br>';
                
    $body .= 'We have captured your details for the business you are interested in and will be contacting you shortly.<br><br>';
                
    $body .= 'Warm Regards,<br><br>';
                
    $body .= 'Business Group<br>';
                
    $body .= 'www.website.com<br>';
                
    $body .= 'www.website2.com';
                
    mail($email$title$body$headers);
                echo 
    'Thank you, we will get back to you as soon as possible.<br>';
       }
    }
    // Add this code to check if the mail function was executed.
    if(!$mail_it) {
        echo 
    'Oops, something went wrong.';
    } else {
        echo 
    'Mail sent.';
    }
    ?>
    Learn SEO - Join the community at GSEO.net
    SEO Book - SEO Revenge eBook
    Make Money Programs - No Fluff!
    Make Money Online

  10. #10
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
    The single quotes mean use these values as literals, not use these variables...
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  11. #11
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by byron3@earthlink View Post
    VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
    The single quotes mean use these values as literals, not use these variables...
    No, it means they're strings, and thus get enclosed with single quotes in SQL. That is part of a PHP string that's enclosed in double quotes, so those variables will be parsed.

  12. #12
    SitePoint Enthusiast dannbkk's Avatar
    Join Date
    Jan 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do i get the information of theses values also sent to my email so like the sellers name once filled his email and everything else etc. as its now not emailing me with that info which it should.. please help...

    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = ereg_replace("[^0-9+ ]", "", $_POST['phone']);
    $enquiry = ereg_replace("\n", "<br>", $_POST['enquiry']);
    $reference = $_POST['reference'];
    Learn SEO - Join the community at GSEO.net
    SEO Book - SEO Revenge eBook
    Make Money Programs - No Fluff!
    Make Money Online


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
  •