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
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending a form to an email address - please help :)

    Hi all,

    I'm trying to make a 'contact us' page for a website and want a form that allows the user to input their name, email address, and comment then send it to my hotmail account using a submit button. I've tried various things but it doesn't appear to be working. I've visited other forums and the general consensous is that it can be done fairly simply without the use of php etc, but I've yet to find anything that works. I'm reasonably new to programming so the simpler the better at the moment

    Thank you in advance

    Kate

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Oxford, UK
    Posts
    422
    Thanks
    14
    Thanked 27 Times in 27 Posts
    Do you know what web server you are using?

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    74
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by katef View Post
    Hi all,

    I'm trying to make a 'contact us' page for a website and want a form that allows the user to input their name, email address, and comment then send it to my hotmail account using a submit button. I've tried various things but it doesn't appear to be working. I've visited other forums and the general consensous is that it can be done fairly simply without the use of php etc, but I've yet to find anything that works. I'm reasonably new to programming so the simpler the better at the moment

    Thank you in advance

    Kate
    Are you looking for something like the one below:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Contact details</title>
    </head>

    <body>
    <form action="mailto:emailid@gmail.com" method="post" enctype="text/plain" >
    Name:
    <input type="text" name="Name" />
    Email:
    <input type="text" name="Email" />
    Comments:
    <textarea name="Comments"></textarea>
    <input type="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html>


    But this is not recommended. The best is to use any server side script like perl or php. Its simple and systematic.


    Regards,
    Last edited by frankle; 06-02-2009 at 12:22 PM.

  • #4
    Regular Coder noneforit's Avatar
    Join Date
    Apr 2009
    Location
    England
    Posts
    268
    Thanks
    10
    Thanked 20 Times in 20 Posts
    It can be done without PHP as Frankle says above but i would reccomend using PHP if the web server supports it. It would only need a few lines of PHP code to work

  • #5
    Regular Coder noneforit's Avatar
    Join Date
    Apr 2009
    Location
    England
    Posts
    268
    Thanks
    10
    Thanked 20 Times in 20 Posts
    Right.....

    Copy the PHP code below into notepad and save it as something like form.php. Make sure you edit the $webmaster variable with your own email address and change the thanks.html to a page on your site.

    PHP Code:
    <?php

    /* Subject and Email Variables */

        
    $emailsubject 'Contact Form';
        
    $webMaster 'something@example.com';
        
    /* Gathering Data Variables */

        
    $name $_POST['name'];
        
    $email $_POST['email'];
        
    $message $_POST['message'];
        
        
    $body = <<<EOT
    Name: $name 
    Email: $email 
    Message: $message 
    EOT;

        
    $headers "From: $email\r\n";
        
    $headers .= "Content=type: text/html\r\n";
        
    /* Emailing the Form */

        
    mail($webMaster$emailsubject$body$headers);
        
    /* Directing the User to the Webpage thanks.html */
        
    header('Location: thanks.html');
    ?>
    Then copy the HTML code below into your contact page. May need to edit the action="contactform.php" if you called the php document above anything other than contactform.


    Code:
    <form name="contactform" method="post" action="contactform.php">
                <p align="center">&nbsp;</p>
                <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#A0AFCB" width="100%">
                  <tr>
                    <td width="50%" align="center">Name:<p>&nbsp;</td>
                    <td width="50%" align="center">
                    <input type="text" name="name" size="25"><p>&nbsp;</td>
                  </tr>
                  <tr>
                    <td width="50%" align="center">Email Address:</td>
                    <td width="50%" align="center">
                    <input type="text" name="email" size="25"></td>
                  </tr>
                </table>
                <p align="center">&nbsp;</p>
                <p align="center">&nbsp;</p>
                <p align="center">Message:</p>
                <p align="center">&nbsp;</p>
                <p align="center"><textarea rows="12" name="message" cols="38"></textarea></p>
                <p align="center">&nbsp;</p>
                <p align="center"><input type="submit" value="Submit" name="B1">&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="reset" value="Reset" name="B2"></p>
              </form>
    Upload both to the webserver in the same folder, go to the contact page, fill it in and click submit. This should email the form content to yourself


  •  

    Posting Permissions

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