Results 1 to 10 of 20

Thread: Day 12 - Sending Mail From PHP - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/contact.php

    Code:
    <?php
    
    
    if (isset($_POST['submit'])) {
       $fromEmail = $_POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body,
    'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } else {
    
    
    echo
     
    '<!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">  
    <title>Contact Us</title>
    </head>
    <body>
    <form action="contact.php" method="POST">  
    Email<br>    <input type="text" name="fromEmail"><br>   
    Message<br>  <textarea name="body" cols="30" rows="10"></textarea>  
    <br>    <button type="submit" name="submit" value="submit">Send Mail</button></form>
    </body></html>  
    ';}

  2. #2
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/contact.php

    Code:
    <?php
    
    
    if (isset($_POST['submit'])) {
       $fromEmail = $_POST['fromEmail'];
        $body = $_POST['body'];
        mail('[email protected]','Message from web site', $body,
    'From: ' . $fromEmail . "\n\r");
        echo 'Thank you for contacting us.';
    } else {
    
    
    echo
     
    '<!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">  
    <title>Contact Us</title>
    </head>
    <body>
    <form action="contact.php" method="POST">  
    Email<br>    <input type="text" name="fromEmail"><br>   
    Message<br>  <textarea name="body" cols="30" rows="10"></textarea>  
    <br>    <button type="submit" name="submit" value="submit">Send Mail</button></form>
    </body></html>  
    ';}
    Very nice script :)

    If [email protected] is not your email address, it is better change it. If not if some one submit that form, we will mail the content to [email protected], that will be like sending spam.. as he don't want us to send him such mails.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Tags for this Thread

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
  •