How do you make contact forms?

Discussion in 'HTML & Website Design' started by Website Tiger, Sep 16, 2008.

  1. #1
    I've done everything in the web design field :) except contact forms :(, does anyone have a tutorial link on how to make contact forms using cgi script or javascript/SMTP? I have come across form generators but I need the cgi script or ajax.
     
    Website Tiger, Sep 16, 2008 IP
  2. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #2
    scottlpool2003, Sep 17, 2008 IP
  3. MarcinST3333

    MarcinST3333 Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, I think that PHP is great for forms. Once you've submitted your form you collect all the information using something like this:

    $_POST['field_name']

    For example if you have just one text field just called yourname, you can use it by something like this:

    $name = $_POST['yourname'];
    echo 'Hello, ' . $_POST['yourname'];
     
    MarcinST3333, Sep 17, 2008 IP
  4. scubita

    scubita Peon

    Messages:
    5,550
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #4
    scubita, Sep 17, 2008 IP
  5. CaffinePhil

    CaffinePhil Banned

    Messages:
    945
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    CaffinePhil, Sep 17, 2008 IP
  6. web-realtor

    web-realtor Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    web-realtor, Sep 17, 2008 IP
  7. SearchBliss

    SearchBliss Well-Known Member

    Messages:
    1,899
    Likes Received:
    70
    Best Answers:
    2
    Trophy Points:
    195
    Digital Goods:
    1
    #7
    A lot depends on what scripts you can run on your server. I have an NT server, so I cannot run PHP, so I use vbScript (ASP). I can give you my script, if you have a Microsoft server...otherwise, sorry I can't help.

    P.S. Where did you generate the form?
     
    SearchBliss, Sep 17, 2008 IP
  8. Website Tiger

    Website Tiger Guest

    Messages:
    351
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    heres the php code I'm using

    <?PHP
    $to = "tigersites@live.com"; 
    $subject = "Information";
    $headers = "From: Form1";
    $forward = 0;
    $location = "";
    
    $date = date ("l, F jS, Y"); 
    $time = date ("h:i A"); 
    
    
    $msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n"; 
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
        foreach ($_POST as $key => $value) { 
            $msg .= ucfirst ($key) ." : ". $value . "\n"; 
        }
    }
    else {
        foreach ($_GET as $key => $value) { 
            $msg .= ucfirst ($key) ." : ". $value . "\n"; 
        }
    }
    
    mail($to, $subject, $msg, $headers); 
    if ($forward == 1) { 
        header ("Location:$location"); 
    } 
    else { 
        echo "Thank you, we will get back to you ASAP."; 
    } 
    
    ?>
    Code (markup):
    Heres the test version http://websitetiger.freehostia.com/2/ . I've used live.com (hotmail) and aim.com but both don't work could that be the problem?
     
    Website Tiger, Sep 17, 2008 IP
  9. tjsocr22

    tjsocr22 Active Member

    Messages:
    1,251
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    80
    #9
    Unfortunately I don't think you can make a good script using javascript or html. The only way you could really code something to do a specific task such as using e-mail, you have to use PHP. If you search on Google you will find many scripts that allow you to make a contact form :).
     
    tjsocr22, Sep 17, 2008 IP
  10. w0lfenst1en

    w0lfenst1en Well-Known Member

    Messages:
    128
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #10
    hey man use php thats the only way now to make better contact forms
     
    w0lfenst1en, Sep 17, 2008 IP
  11. Website Tiger

    Website Tiger Guest

    Messages:
    351
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yeah I'm using PHP now but look at my post before this one I have the code there it just doesn't work, I'm guessing its because of the email, not sure though...
     
    Website Tiger, Sep 17, 2008 IP