Will pay for help - Form to Email simple script

Discussion in 'PHP' started by khullarmd, Dec 1, 2009.

  1. #1
    need this form (http://www.ezstudentrentals.com/index-5.html) to go to an email address.

    You can use a sample script online to make it work, I just do not have the time for this.

    Email offers and time period when you will be able to do it.
     
    khullarmd, Dec 1, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    you mean when somebody submits this form an email should be sent on a specified email id with details filled in?

    Is that the only thing or you also want a copy of details in database?
     
    mastermunj, Dec 1, 2009 IP
  3. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #3
    Here enjoy :p


    
    <?php
    // Settings
    // WHere the user came from
    $previous_file = "";
    // Where do you want the email sent?
    $to = "ezstudentrentals@gmail.com";
    // What should the email subject say?
    $subject ="";
    
    // Function thanks to http://www.phpro.org/tutorials/PHP-Security.html
    function safeEmail($string)
    {
        return  preg_replace( '((?:\n|\r|\t|%0A|%0D|%08|%09)+)i' , '', $string );
    }
    // message
    // email
    // telephone
    // last_name
    // first_name
    if(!empty($_POST['first_name']) && !empty($_POST['last_name']) && !empty($_POST['telephone']) && !empty($_POST['email']) && !empty($_POST['message'])) {
        // Fetch and sanitize input
        $first_name = safeEmail($_POST['first_name']);
        $last_name = safeEmail($_POST['last_name']);
        $email = safeEmail($_POST['email']);
        $telephone = safeEmail($_POST['telephone']);
    
        $header = "From:  < ".$email." >\n
    To: ".$to."\n
    Subject: ".$subject."\n
    Date: ".date("Y-m-d h:i")."\n
    Reply-to: ".$email."\r\n
    ";
    
        $message = "From your form\n\nUserdetails\nFirst Name: ".$first_name."\nLast Name: ".$last_name."\nTelephone: ".$telephone."\nEmail: ".$email."\n" . safeEmail($_POST['message']);
    
        if(mail($to,"Contactform ",$message, $header)) {
            header("refresh: 3;url=".$previous_file);
            print("Email sent");
        } else {
            header("refresh: 3;url=".$previous_file);
            print("An error occured: Could not send the email");
        }
    
    } else {
        header("refresh: 3; url=".$previous_file."");
        print("You did not fill out the whole form");
    }
    ?>
    
    PHP:
     
    n3r0x, Dec 1, 2009 IP
  4. khullarmd

    khullarmd Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks so much.
     
    khullarmd, Dec 1, 2009 IP
  5. khullarmd

    khullarmd Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Project completed. Thanks
     
    khullarmd, Dec 1, 2009 IP