Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts

    Help With Email Script

    I made a small email script that i cant seem to get to send an email. I was wondering if anyone had the time to look over this code and give me a suggestion.

    Form:
    Code:
    <form method="POST" action="remove_me.php">
    <table border="0" cellspacing="5" cellpadding="5">
    <tr>
    <td>Name:</td><td><input type="text" name="name" size="25" /></td>
    </tr>
    <tr>
    <td>Badge #:</td><td><input type="text" name="badge" size="25" maxlength="3" /></td>
    </tr>
    <tr>
    <td>Class Name:</td><td><input type="text" name="className" size="25" /></td>
    </tr>
    <tr>
    <td>Class Date:</td><td><input type="text" name="date" size="25" /></td>
    </tr>
    <tr>
    <td>Password:</td><td><input type="password" name="password" size="25" /></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="submit" value="Submit Request" />&nbsp;<input type="reset" name="reset" value="Reset" /></td>
    </tr>
    </table>
    </form>
    remove_me.php:
    PHP Code:
    <?php
    $name 
    $_POST["name"];
    $badge $_POST["badge"];
    $className $_POST["className"];
    $date $_POST["date"];
    $password $_POST["password"];
    $pw "password";
    $to "rappa819@gmail.com";
    $subject "Class Remove Request";
    $message "$name\n$badge\n$className\n$date";

    if (empty(
    $name) || empty($badge) || empty($className) || empty($date) || empty($password)) {
    echo 
    "Please Fill In All The Fields. <a href=\"removeme.php\">Back</a>";
    }
    else if (
    $password != $pw) {
    echo 
    "Invalid Password. <a href=\"removeme.php\">Back</a>";
    }
    else if (!empty(
    $name) && !empty($badge) && !empty($className) && !empty($date) && $password == $pw) {

        if (
    mail($to$subject$message)) {
        echo 
    "Request Successfully Sent";
        }
        else {
        echo 
    "Failed to send Removal Request";
        }
    }
    ?>
    At least i get the "Failed to..." echo. But i dont know why its not sending. Im not that great with php as you see.

    Thanks in advance.

  • #2
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    Quick send mail scripts.

    http://www.w3schools.com/php/php_mail.asp

    http://www.php-scripts.com/php_diary/122899.php3

    Hope they help you understand what you need done, better.

    Cheers

  • #3
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Put error_reporting ( E_ALL ) at the top of your script and see if you get any warnings or notices.

    Are you sure the SMTP is set up in your php.ini?

  • #4
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Try putting:

    PHP Code:

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

    // then do this... 


    Hope that helps. Best regrades,

    Jon W


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •