Help with setting up a form

Discussion in 'HTML Development' started by Mcdogs, May 10, 2006.

  1. Mcdogs Web Designer

    Hi everyone, I was wondering whether there is a tutorial somewhere that can help me in setting up a basic contact form, I have tried before but it never seems to work, I can set up the form no problem its just processing it through the server I cant seem to get me head around.

    Any help would be appreciated
  2. BurningSnowman Moderator

    I posted an example contact form in the code repository recently, but making your own should be easy enough with a basic knowledge of PHP and use of the mail() function.

    Loads of premade scripts also exist, which will obviously be more customisable than my demo one, though some are suspectible to the security vulnerabilities that my demo set out to avoid.

    There are also lots of tutorials for contact forms in PHP, this and this being a couple of easily found examples, but note that both of those look like they'll be susceptible to the header 'injection' exploit, which could mean major spam abuse of the server under your account, and thus lots of trouble. The second one also looks like it would require register_globals on, and its use of request variables definitely isn't good practice. Those tutorials still provide a bit more explanation of the general approach, if my own example script seems a bit... long. I obviously wouldn't recommend using them without patching up that main security issue, though.
  3. Mcdogs Web Designer

    OK I know I am a pain but I am trying to get my head round forms still, just basic ones, not php ones for now, I have set this page up http://www.kbcleaningservices.com/contact.htm How do I get this form to work and then the page forwarded to a page called thankyou.htm

    Any help would be really appreciated
  4. BurningSnowman Moderator

    You cannot send e-mail with the server without a server side script.

    If you just want to launch someone's mail client, I think you can set the target to a mailto, thus launching a user's mail client, and pre-fill certain fields in a new e-mail based on form entries, but that's pretty much the definition of user-unfriendly.

    If you want a working mail form, PHP's mail() function is about as simple a starting point as they come.

    Edit: Moved from E-mail and WebMail Support to HTML Development.
  5. JohnC < ? />

    Hi McDogs, I've just tried to send a message through that page but I got this error message:
    It looks as though you're already hooked up to some sort of script to process the form, but it's not set up properly.
    This bit of your page:
    Code:
    <form name="form1"action="http://www.kbcleaningservices.com/cgi-bin/cgiemail/contact.txt" method="POST">
    confirms you're using cgiemail.
    If you want to use a php script you have to change the
    [action=".....] bit to send the form data to the script you're going to use. Have a look at the form BurningSnowman posted up.
  6. BurningSnowman Moderator

    Yup, and if you're using a CGI thingamy, you need to point it there exactly the same. Which is what I meant: you need something on the server side, whatever language it may be in.

Share This Page