Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2006
    Location
    Nottinghamshire
    Posts
    184
    Tokens
    0

    Default [PHP - Beginner] Creating A Contact Form

    This tutorial is for beginners to php but if an advanced user does not know how to do it then it will be good for them too.

    This tutorial is on how to create a contact form that sends to you email but the sender does not have to reveal his/her's email

    First you need to create the form:

    <form name="Contact Form" method="post" action="sendmail.php">
    <p> Name
    <input type="text" name="Name">
    </p>
    <p> Reason for Contacting
    <select name="Reason">
    <option value="Problem">Problem With Site</option>
    <option value="Advert Inquiry">Advertising Inquiry</option>
    <option value="Question">Question</option>
    <option value="Bug Report">Bug Report</option>
    </select>
    </p>
    <p>Message</p>
    <p>
    <textarea name="Message"></textarea>
    </p>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    Try to make you names for the inputs simple as you will need use these later on.

    Now make a new file called 'sendmail.php'
    This should consist of:
    <?php
    $name = $_REQUEST['name'] ;
    $reason = $_REQUEST['reason'] ;
    $message = $_REQUEST['message'] ;

    mail( "[email protected]", "Contact Form",
    "$name
    $reason
    $message", "From: $name" ) ;
    ?>
    Ok, now lets explain each bit now.

    First lets explain this:
    $name = $_REQUEST['name'] ;
    $reason = $_REQUEST['reason'] ;
    $message = $_REQUEST['message'] ;
    The $name/$reason/$message bit try to keep relative to the data that it means. For example $name is relavent to Name etc. etc.
    The $_REQUEST['name'] ; bit is saying that it's requesting data from the textfield named name. So the bit in those square bracket things need to be the name of the input field it's requesting data from.

    Now, I'll explain this bit:
    mail( "[email protected]", "Contact Form",
    "$name
    $reason
    $message", "From: $name" ) ;
    The 'mail( "[email protected]", "Contact Form"' mail bit means it is going to send the data by email. The email address is what email addy it is going to send to and the 'Contact Form' is what the message subject will be. Now the, $name/$reason/$message is there so in the message it will display those data from the form fields of your form. and the "From: $name' means that the email 'Form' bit will be the name that the person entered into the form.

    Ok, I hope that was clear enough. if it isn't just say and I will clear it up for you.
    Last edited by The Voice; 01-08-2006 at 08:58 AM.

  2. #2
    Join Date
    Jul 2006
    Posts
    38
    Tokens
    0

    Default

    Nice tut! :}

  3. #3
    Join Date
    Aug 2004
    Location
    England
    Posts
    1,028
    Tokens
    0

    Latest Awards:

    Default

    Yeah, seems pretty good.

  4. #4
    Join Date
    Jun 2006
    Location
    Nottinghamshire
    Posts
    184
    Tokens
    0

  5. #5
    Join Date
    Apr 2006
    Location
    West Midlands
    Posts
    3,384
    Tokens
    0

    Latest Awards:

    Default

    Seems pretty gd

    I havn't tried it though.

  6. #6
    Join Date
    May 2006
    Location
    Cymru
    Posts
    2,157
    Tokens
    2,925

    Latest Awards:

    Default

    Nice Job
    Last edited by Jargit; 01-08-2006 at 10:50 AM.

Posting Permissions

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