+ Reply to Thread
Results 1 to 10 of 10

Thread: HTML Form to email?

  1. #1
    verticalnfinity is offline x10Hosting Member verticalnfinity is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    11

    HTML Form to email?

    Hi! I've been trying to get my HTML form to send the data to my email but all has failed.

    I tried CGI email but they just don't work. Here are my settings for the CGI email. I hope they are right. (Attachments)

    I also need the right steps cause the user guide just confuses me even more.

    It would be great if you could help me as I really need this and I would like to learn. Thanks!
    Attached Files

  2. #2
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: HTML Form to email?

    I've never heard of any 'script' like your outing.txt ...
    Try to make a file "outing.php" (and also put it as the action of the form)
    PHP Code:
    <?php
    $text  
    "Name: {$_POST["required-name"]}\n";
    $text .= "Email: {$_POST["email"]}\n";
    $text .= "Phone number: {$_POST["phone"]}\n";
    $text .= "Attending: {$_POST["attendance"]}\n";
    $text .= "Comments: {$_POST["comment"]}";

    mail("vt@8473973495.com""Outing Attendance"$text);
    ?>
    Not the best php script i've made, but it should at least do something (unlike that txt file...)
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  3. #3
    verticalnfinity is offline x10Hosting Member verticalnfinity is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    11

    Re: HTML Form to email?

    OMG! It worked! But is there any way to like make the php page have some words or a redirection page? :D

    That would work great. Thanks a lot!

    Edit: Oh wait. I can use HTML! That'll work great! :D (I think)
    Last edited by verticalnfinity; 08-31-2008 at 09:22 PM.

  4. #4
    dbqclassof2012 is offline x10Hosting Member dbqclassof2012 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    15

    Lightbulb Re: HTML Form to email?

    Yes there is a way for the that to happen all you have to do is put your outgoing.php file in html tags like this
    HTML Code:
    <html>
    <head>
    <title>Congratulations your email has been sent!</title>
    <meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
    </head>
    <body>
     <?php 
    $text  = "Name: {$_POST["required-name"]}\n"; 
    $text .= "Email: {$_POST["email"]}\n"; 
    $text .= "Phone number: {$_POST["phone"]}\n"; 
    $text .= "Attending: {$_POST["attendance"]}\n"; 
    $text .= "Comments: {$_POST["comment"]}"; 
    
    mail("vt@8473973495.com", "Outing Attendance", $text); 
    ?>  
    <!-- Now Put what you want in your page here -->
    Congratulations Your Email Has Been Sent!
    
    </body>
    </html>
    The Number 5 in
    Code:
    <meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
    Is how many seconds till the page will be automatically redirect

    I believe this is how it works i have the same type of thing for my website.

    Hope I helped!;)
    Thought I did a good job? Please Donate some credits or give some rep.



    :laugh:Thanks:laugh:

  5. #5
    verticalnfinity is offline x10Hosting Member verticalnfinity is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    11

    Re: HTML Form to email?

    Is there anyway to make a required field? Help appreciated
    Edit:
    Quote Originally Posted by dbqclassof2012 View Post
    Yes there is a way for the that to happen all you have to do is put your outgoing.php file in html tags like this
    HTML Code:
    <html>
    <head>
    <title>Congratulations your email has been sent!</title>
    <meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
    </head>
    <body>
     <?php 
    $text  = "Name: {$_POST["required-name"]}\n"; 
    $text .= "Email: {$_POST["email"]}\n"; 
    $text .= "Phone number: {$_POST["phone"]}\n"; 
    $text .= "Attending: {$_POST["attendance"]}\n"; 
    $text .= "Comments: {$_POST["comment"]}"; 
    
    mail("vt@8473973495.com", "Outing Attendance", $text); 
    ?>  
    <!-- Now Put what you want in your page here -->
    Congratulations Your Email Has Been Sent!
    
    </body>
    </html>
    The Number 5 in
    Code:
    <meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
    Is how many seconds till the page will be automatically redirect

    I believe this is how it works i have the same type of thing for my website.

    Hope I helped!;)
    Thanks alot that helped. now I need to do a required field for the form. Any ideas?
    Last edited by verticalnfinity; 08-31-2008 at 10:27 PM. Reason: Automerged Doublepost

  6. #6
    dbqclassof2012 is offline x10Hosting Member dbqclassof2012 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    15

    Re: HTML Form to email?

    I am not sure how to do this but just Google "how to make a form required" and just keep looking around.

    Sorry i am not able to help with this.
    Thought I did a good job? Please Donate some credits or give some rep.



    :laugh:Thanks:laugh:

  7. #7
    scopey is offline x10Hosting Member scopey is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    62

    Re: HTML Form to email?

    So a user HAS to enter something?

    Just check it to see if it's empty with php.

    if($_POST['field'] == ""){
    echo "You fail. Enter a value in fieldname"
    }
    - When in doubt, refer to the PHP manual.

  8. #8
    mujtaba91's Avatar
    mujtaba91 is offline x10Hosting Member mujtaba91 is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Doha
    Posts
    50

    Re: HTML Form to email?

    Well its better to validate a form using javascript since it is not executed on server,saves time and looks impressive..
    Here is the scipt:


    <script type="text/javascript">




    <!--

    function validate_form ( )
    {
    valid = true;

    if ( document.myform.required_field.value == "" )
    {
    alert ( "Please enter your name!" );
    document.myform.name.style.border='1px solid red';
    valid = false;
    }



    return valid;
    }

    //-->

    </script>


    And the HTML:

    <form action="outing.php" method="post" onsubmit="return validate_form ( );" name="myform" >

  9. #9
    verticalnfinity is offline x10Hosting Member verticalnfinity is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    11

    Re: HTML Form to email?

    Thanks a lot guys! Will try and see how it goes

  10. #10
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: HTML Form to email?

    *wheeeeee, let's post responses that are actually incorrect! =D*

    Ok, clearly, a client-side validation is useless, as the user is able to go around that very easely. Just use the server-side validation. (In the PHP code.) (Usually the 2 are combined.)
    The META-redirect should work, but is not the recommended way to do things...

    Required field:
    PHP Code:
    <?php
    //Checks required-name
    if($_POST["required-name"] == "") {
    ?>
    HTML CODE FOR FAILED VALIDATION GOES HERE.
    <?php
    //Or: to use a redirect, remove the 3 above lines and use a header("Location: url");
    exit;
    }
    $text  "Name: {$_POST["required-name"]}\n";
    $text .= "Email: {$_POST["email"]}\n";
    $text .= "Phone number: {$_POST["phone"]}\n";
    $text .= "Attending: {$_POST["attendance"]}\n";
    $text .= "Comments: {$_POST["comment"]}";

    mail("vt@8473973495.com""Outing Attendance"$text);
    ?>
    If you want to redirect:
    PHP Code:
    <?php
    $text  
    "Name: {$_POST["required-name"]}\n";
    $text .= "Email: {$_POST["email"]}\n";
    $text .= "Phone number: {$_POST["phone"]}\n";
    $text .= "Attending: {$_POST["attendance"]}\n";
    $text .= "Comments: {$_POST["comment"]}";

    @
    mail("vt@8473973495.com""Outing Attendance"$text);
    header("Location: http://www.google.com");
    exit;
    ?>
    To use html:
    PHP Code:
    <?php
    $text  
    "Name: {$_POST["required-name"]}\n";
    $text .= "Email: {$_POST["email"]}\n";
    $text .= "Phone number: {$_POST["phone"]}\n";
    $text .= "Attending: {$_POST["attendance"]}\n";
    $text .= "Comments: {$_POST["comment"]}";

    mail("vt@8473973495.com""Outing Attendance"$text);
    ?>

    PUT HTML HERE.

    - Marshian
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers