Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Help with understanding a contact form

Options
  • 17-03-2008 12:10am
    #1
    Registered Users Posts: 4,109 ✭✭✭


    Hello all, I've just started my own company and am doing up a site from a template I found online for Dreamweaver. (I should say at this time I have never done any coding...what so ever) I'm on the contact section and I want to put in a form with Name, email, Subject and then a text body. I have one for the template but dont know how to edit/modify it to send the forum to me in a email or any other way that it might be done. Here is the code that I have...

    <form name="form1" method="post" action="">
                  <table width="90%" border="0" cellspacing="2" cellpadding="4">
                    <tr> 
                      <td width="10%" align="right" valign="top"><b>Name:</b></td>
                      <td colspan="2" valign="top"> <input name="textfield" type="text" size="30"> 
                      </td>
                    </tr>
                    <tr> 
                      <td width="10%" align="right" valign="top"><b>Email:</b></td>
                      <td colspan="2" valign="top"> <input name="textfield2" type="text" size="30"> 
                      </td>
                    </tr>
                    <tr> 
                      <td width="10%" align="right" valign="top"><b>Subject:</b></td>
                      <td colspan="2" valign="top"> <input name="textfield2" type="text" size="30"> 
                      </td>
                    </tr>
                    <tr> 
                      <td valign="top" align="right" width="10%"><b>Message:</b></td>
                      <td colspan="2" valign="top"> <textarea name="textfield2" rows="5" cols="30"></textarea> 
                      </td>
                    </tr>
                    <tr> 
                      <td width="10%" align="right">&nbsp; </td>
                      <td colspan="2"> <input type="submit" name="Submit" value="Send"> 
                      </td>
                    </tr>
                  </table>
                </form>
    
    I take it what I want to edit is the "action" at the top. But what do I put in there? Any thoughts?


Comments

  • Registered Users Posts: 597 ✭✭✭yeraulone


    You'll need a script to process the form and send it to an email address. What type of server will the site be hosted on (windows or linux)? Does it support php or asp? There are other options too like CGI etc.


  • Registered Users Posts: 397 ✭✭Design_Dude


    You want one that the info will get sent straight to you? I can make you one, with an autoresponder back to the person as well if you want. And you wont need any script hosting (asp etc) its all in the html script.


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    You want one that the info will get sent straight to you? I can make you one, with an autoresponder back to the person as well if you want. And you wont need any script hosting (asp etc) its all in the html script.

    How is that possible, Design_Dude ?

    I know that you could (in theory) do a mailto: but if someone's using an internet cafe or uses hotmail, gmail, etc, then it won't work.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    You can do it through the server if you have PHP.
    Havn't tested it though and looks messy sorry but no time atm.

    Something like:

    [php]<?php
    $sent = $_GET;

    if (isset($_GET))
    {
    $name = $_POST;
    $email = $_POST;
    $subject = $_POST;
    $message = $_POST;

    $receiveremail = 'youremail@yourhost.com';
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'From: '.$email."\r\n";
    $message = '<html>
    <head>
    <title>We got an Email!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style>
    body{
    font-family: arial;
    font-size: 12px;
    }
    </style>
    </head>

    <body>
    <p>Hi,<br>
    A message was sent from {MySite}<br>
    From: <strong>'.$name.'</strong><br>
    Their Email: <strong>'.$email.'</strong><br></p>
    Their Subject: <strong>'.$subject.'</strong><br></p>
    <p>Their Message:<br> <strong>'.$message.'</strong></p>
    </body>
    </html>
    ';

    if (@mail($receiveremail,"A New Contact From {MySite}",$message,$headers))
    {

    print "<p align=\"left\">Thanks for your message! We will receive it shortly.</p><br>";
    print "<p align=\"left\"><strong>Name: </strong>".$name."<br>
    <strong>Email: </strong> ".$email."<br>
    <strong>Query: </strong> ".$query."</p>";
    } else
    {
    print "<p><strong>We are sorry</strong>, the server is experiencing some difficulty at the moment.<br /> Please try again later or refresh the page.</p>";
    }
    }
    else
    {
    ?>
    <form name="form1" method="post" action="<?php $_SERVER; ?>?sent=true">
    <table width="90%" border="0" cellspacing="2" cellpadding="4">
    <tr>
    <td width="10%" align="right" valign="top"><b>Name:</b></td>
    <td colspan="2" valign="top"> <input name="name" type="text" size="30">
    </td>
    </tr>
    <tr>
    <td width="10%" align="right" valign="top"><b>Email:</b></td>
    <td colspan="2" valign="top"> <input name="email" type="text" size="30">
    </td>
    </tr>
    <tr>
    <td width="10%" align="right" valign="top"><b>Subject:</b></td>
    <td colspan="2" valign="top"> <input name="subject" type="text" size="30">
    </td>
    </tr>
    <tr>
    <td valign="top" align="right" width="10%"><b>Message:</b></td>
    <td colspan="2" valign="top"> <textarea name="message" rows="5" cols="30"></textarea>
    </td>
    </tr>
    <tr>
    <td width="10%" align="right">  </td>
    <td colspan="2"> <input type="submit" name="Submit" value="Send">
    </td>
    </tr>
    </table>
    </form>
    <?php
    } //end else
    ?>[/php]


  • Registered Users Posts: 397 ✭✭Design_Dude


    Liam Byrne wrote: »
    How is that possible, Design_Dude ?

    I know that you could (in theory) do a mailto: but if someone's using an internet cafe or uses hotmail, gmail, etc, then it won't work.

    It uses a different website as its server for sending the emails, and also send an automated response if you want.


  • Advertisement
  • Registered Users Posts: 2,919 ✭✭✭Bob the Builder


    hey,

    what I usually use, and what I think you should use as well is this. You type in the variables of the contact forum and it will output three files that you can copy and paste onto your page.it saves so much time.

    Good Luck.
    Nev


  • Registered Users Posts: 397 ✭✭Design_Dude


    Yea, ive used that, its pretty good alrite:)


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    It uses a different website as its server for sending the emails, and also send an automated response if you want.

    OK, that explains it.....it DOES use php/asp/cf/perl or whatever, but it's just that he doesn't need to host it.

    Cheers!


  • Registered Users Posts: 397 ✭✭Design_Dude


    aye


  • Registered Users Posts: 4,109 ✭✭✭sutty


    Cool thanks for the reply's lads, I got it working in the end by finding a scripting tool on my web hosting service provider. One thing I am interested in doing now is adding in a anti spam random number gen and key entry field. Would this be hard to do? What would I need to be able to host the gen local to my site (so I am not dependent on an other website/server being up)


  • Advertisement
Advertisement