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 5 of 5

Thread: Submit To Email

  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    61
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question Submit To Email

    How do i make a form submit to an email?

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    61
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question

    So How Do I Add This Code:

    Code:
    <?php
    //define the receiver of the email
    $to = 'Dwightshwrute@yahoo.com;
    //define the subject of the email
    $subject = 'Test Email'; 
    //define the message to be sent. Each line should be separated with \n
    $message = "Hello World!\n\nThis is my first mail."; 
    //define the headers we want passed. Note that they are separated with \r\n
    $headers = "From: Dwightshwrute@yahoo.com\r\nReply-To: Dwightshwrute@yahoo,com";
    //send the email
    $mail_sent = @mail( $to, $subject, $message, $headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent ? "Mail sent" : "Mail failed";
    ?>
    To This Code:

    Code:
    <html>
    <body>
    
    <form name="input" action="html_form_action.asp" method="get">
    Male: 
    <input type="radio" name="Sex" value="Male" checked="checked">
    <br>
    Female: 
    <input type="radio" name="Sex" value="Female">
    <br>
    <input type ="submit" value ="Submit">
    </form> 
    
    </body>
    </html>
    To Make It Work? Or Is Something Wrong In These Codes?

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    You missed to close your string:
    Code:
    <?php
    //define the receiver of the email
    $to = 'Dwightshwrute@yahoo.com';
    //define the subject of the email
    $subject = 'Test Email'; 
    .
    .
    .
    I don't understand what you're doing. It seemed that your form's action is pointing to an ASP page, and what you have is a PHP script.

    This works:
    PHP Code:
    <?php
    if(isset($_POST['submit']))
    {
    //define the receiver of the email
    $to 'Dwightshwrute@yahoo.com';
    //define the subject of the email
    $subject 'Test Email'
    //define the message to be sent. Each line should be separated with \n
    $message "Hello World!\n\nThis is my first mail."
    //define the headers we want passed. Note that they are separated with \r\n
    $headers "From: Dwightshwrute@yahoo.com\r\nReply-To: Dwightshwrute@yahoo,com";
    //send the email
    $mail_sent mail$to$subject$message$headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent "Mail sent" "Mail failed";
    }
    ?>
    <html>
    <body>
    <form name="input" action="<?php echo $_SERVER['php_self']; ?>" method="post">
    Male: 
    <input type="radio" name="Sex" value="Male" checked="checked">
    <br>
    Female: 
    <input type="radio" name="Sex" value="Female">
    <br>
    <input type ="submit" value ="Submit" name="submit">
    </form> 
    </body>
    </html>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    nathan130 (10-29-2008)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    61
    Thanks
    10
    Thanked 0 Times in 0 Posts
    I want to make a form then when someone clicks submit it sends the info they entered to my email address.

    I think that worked but i havent got the email yet so im not sure yet.


  •  

    Posting Permissions

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