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
    Feb 2007
    Posts
    26,214

    Default

    DAY 12 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/day_12_ex_1.php

    PHP Code:

    <?php
    $toEmail 
    'php.flashwebhost.com';$subject 'Email Notification';$body 'Welcome to our Email Service';
    mail($toEmail$subject$body);
    echo 
    'Mail sent to ' $toEmail;

  2. #2
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 12 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/day_12_ex_3.html

    Code:
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Contact Us</title>
    </head>
    <body>
    
    
    <form action="day_12_ex_3.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>

  3. #3
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    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 {
        die('Why are you here ? Want to hack my Script ?');
    }

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
  •