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

Thread: Forms

  1. #1
    Join Date
    Jul 2004
    Posts
    1,457
    Tokens
    0

    Latest Awards:

    Default Forms

    Does anyone know the Script for Forms?

    Thankies ^_^

  2. #2
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Ok forms. well proper ones need to parts. A form handler. and the form itself.

    The form itself only requires html

    It should start with
    HTML Code:
    <form name="form" id="form" method="post" action="LOCATION.php">
    LOCATION.php being the url of the form handler your using.

    In older browsers rather than using the form hanlder you can just send it to your email. youing the mailto tags
    eg
    HTML Code:
    <form name="form" id="form" method="post" action="mailto:[email protected]">
    Athogh in moden browsers this may just send a blank email becuse its no longer supported, by "most" browsers.
    As well as this you dont have as much control over how the data is displayed when sendt to you, or teh abilty to make a thankyou page etc.


    Next you need to put in some inputs.

    for somthing like

    question: ______________

    yuou wouild use

    HTML Code:
    <br>
    question :<input name="title" type="text"  /> 
    <input name="title" type="text" />
    is what makes the text box itself. You can have as many as you like. but they must all have indevidul names so tehy can be told appart

    eg
    <input name="sheep" type="text" />
    <input name="cow" type="text" />

    etc. athogh its probly best if the name is somthing simlar to the question. athogh its best to be one word, so intripter doesnt have anyy problems.

    Another think you could have inside is a text box

    HTML Code:
    <textarea name="message" ></textarea>
    Agian each one must have its own Name.

    a text box is basicly a bigger input. and multi line.

    The only otehr major think you may want in a form is a multi chooise input.

    HTML Code:
    <select name="rate">
                <option>5</option>
                <option>4</option>
                <option>3</option>
                <option>2</option>
                <option>1</option>
              </select>
    The options selctble are 1 to 5. you can ad and removed them in the same way
    and gaina each one needs a new name.

    Secondly, if you wnat an option, to say somthing but have a doffernt value when submited.
    <option value="cow">1</option>
    use that.
    You can also use the value="" tag in the other boxes to have some text alredy written in to them.

    To make a text aria invible. which is mainl yuseful for php scripst but ill say anyway you simply change the type
    from text
    to hidden
    eg
    <input name="info" type="hidden" />
    Or to make the letters invisble typed in in to sploggers (aka a password feild)
    use this
    <input name="info" type="password" />

    finaly we need a submit button
    HTML Code:
    <input type="submit" name="Submit" value="button text">
    Ad that to the end to make a submit button. Also change button text to the text you wnat to display on the button.

    And to end teh form. you just close the form tags.

    HTML Code:
    </form>


    THE FORM HANDLER
    The next part is the php. where you need to use two main functiosn for the most basic form handler. athogh ill also throw in some securty mesuers to prevent spamming.

    Ok here we go.

    MAke sure the page your using. is the one you set as teh form handler loction in the form

    for exsample. LOCATION.php

    as every php file it starts with
    PHP Code:
    <?php
    To tell the host machnine, that it needs to do the php script.

    Then we start the form handler.

    PHP Code:
    if ($_SERVER['REQUEST_METHOD'] != 'GET'){ 
    this makes sure that the infomtion was submited by the form. or at least a form.

    Then we tell it what to do.

    For every input text box, multiple choise question. In the form you will need this bit of code to set it as a varible, in order to email.

    PHP Code:
    $message $_POST['message']; 
    The baove bit is getting the data form a input with the NAME message

    and asigning it to the varible message.

    . You need to do this for all the inputs

    EG
    PHP Code:
    $nam $_POST['name']; 
    $email $_POST['email']; 
    $mess $_POST['message']; 
    $ip $_POST['ip']; 
    Once all the forms data is in varibles you then need to mail it to your email.

    the easyist way is be puuting all the varibles in to one varible

    eg
    PHP Code:
    $messig "

    Name: 
    $nam
    \n
    Email: 
    $email
    \n
    Message: 
    $mess
    \n
    Ip: 
    $ip

    "

    NB: \n is a new line in php
    also you may want a subject ofr the email
    PHP Code:
    $subject $nam
    Now you have teh varible. you send it

    with this bit of code.
    PHP Code:
    mail("[email protected]"$subject$messig); 
    The first part ois your email, or teh email you want to message

    $subject is the messages subject.

    And the 3rd bit is teh actal message, or the varible with the message you made.

    You can send as much or as little data as you like.


    Once youve sent the form. redirect them else where with
    PHP Code:
    Header("Location: thankyoupage.php"); 
    Now what to do is the message want send by a form

    PHP Code:
    }
    else
    {
    echo 
    'ERROR';

    Which just prints error is its veiwed directly.

    And close the form supringly enogh with

    PHP Code:
    ?> 

    i wrote it in a hurry so if ive made any mistakes, please infom me so i can make the relivent changes etc.
    Last edited by Mentor; 20-03-2005 at 10:10 AM.

  3. #3
    Join Date
    Jul 2004
    Posts
    1,457
    Tokens
    0

    Latest Awards:

    Default

    Thank you so much!
    It has works
    altough when someone fills in the form, they're ip isnt show O.o

  4. #4
    Join Date
    Aug 2004
    Location
    United Kingdom
    Posts
    5,769
    Tokens
    1,249
    Habbo
    Beneficial

    Latest Awards:

    Default

    O.o Me too =p
    what is fetch gretchen?

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Ah to get an ip use this value

    value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"

    so the full thionk would be
    Code:
    <input name="ip" type="text"  value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
    ANd if you dont want the editing the feild
    just ad a readonly to the end

    HTML Code:
    <input name="ip" type="text"  value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" readonly>
    keep in mind the contact file would have to be a .php one to be able to use this data :/

  6. #6
    Join Date
    Oct 2004
    Location
    Scotland
    Posts
    2,280
    Tokens
    1,075

    Latest Awards:

    Default

    that must have taken a while.

    http://www.stupidian.com
    (contains mild swearing)

Posting Permissions

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