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!


Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default [TUT] Making a contact form.

    Hello, I am going to take you through the nessecery steps to making a contact form.
    First off i will explain what i am going to do.

    I am going to make two files:
    - One to show the contact form (contact.php)
    and one to send the contact form. (sendmail.php)

    First make a blank page in Notepad or Dreamweaver.
    Before the actull code add this.
    Code:
    <?php
    $ipi = getenv("REMOTE_ADDR");
    ?>
    That will get the users IP address
    The first line of code is the beginning of the form and also tells the data where to output.
    Code:
    <form method="post" action="sendmail.php">
    You can change the "sendmail.php" to whatever you like as long as it complies with the output file.

    Now you need to work out what fields you want. Inn this instance we are going to use:
    -Name (Text Box)
    -Email Address (Text Box)
    -Contact Reason (Drop Down Box)
    -Message (Text Area)

    I will list the input codes for various inputs later on.

    Now to show the Name Box we would put;
    Code:
    Name: <input type="text" name="name" size="30" />
    Now to show the Email Address Box we would put;
    Code:
    Email Address: <input type="text" name="email" size="30" /><br />
    Now the Drop down menu is more complicated.
    Code:
    Contact Reason:<br />
    <select name="reason" size="1">
    <option value="Website Problem">Website Problem</option> 
    <option value="Billing Problem">Billing Problem</option> 
    <option value="Technical Support">Technical Support </option> 
    <option value="Report A Staff Member ">Report A Staff Member</option>
    <option value="Other">Other (Please Specify in message)</option> 
    </select>
    The Name after "Option value="NAME" that is the tag that will be the subject of the email you recieve.

    Finally The Main message.
    Code:
    <textarea name="main" rows="4" cols="30"></textarea>
    You can make the area bigger/smaller by changing the numbers above.

    and now the user will submit the form
    Code:
    <input type="submit" value="Send" />
    and then end the form
    Code:
    </form>
    In the End Looking like this
    Code:
    <form method="post" action="sendmail.php">
    Email Address: <input type="text" name="email" size="30" /><br />
    Contact Reason:<br />
    <select name="reason" size="1">
    <option value="Website Problem">Website Problem</option>
    <option value="Billing Problem">Billing Problem</option>
    <option value="Technical Support">Technical Support </option>
    <option value="Report A Staff Member ">Report A Staff Member</option>
    <option value="Other">Other (Please Specify in message)</option> 
    </select>
    <textarea name="main" rows="4" cols="30"></textarea><br />
    <input type="submit" value="Send" />
    </form>
    Now Call this sendmail.php
    Code:
    <?php
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
    {
    die ("Invalid Email Address"); 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($visitor) || empty($visitormail) || empty($notes )) {
    die ("You didn't fill in all the fields");
    }
    
    $subject = $reason; 
    
    $message = "Reason: $reason \n
    Message: $main \n 
    From: $visitor ($visitormail)\n
    Additional Info : IP = $ip \n
    ";
    
    $from = "From: $email\r\n";
    
    
    mail("YourEmail", $subject, $message, $from);
    
    ?>
    Do Not edit that code unless you know what your doing.
    Where it says
    Code:
    mail("YourEmail", $subject, $message, $from);
    Edit Youremail to The email address you want it to send it to.

    And there you have your contact form.

    Types Of Inputs:
    Text Field
    Code:
    Text Field: 
    <input type="text" name="fieldname">

    Radio Buttons

    Code:
    Options:
    <input type="radio" name="fieldname" value="option 1"> Option 1
    <br>
    <input type="radio" name="fieldname"" value="option 2"> Option 2

    Checkboxes

    Code:
    Options:
    Option 1 
    <input type="checkbox" name="fieldname" value="option 1" />
    <br />
    Option 2
    <input type="checkbox" name="fieldname" value="option 2" />

    Drop Down Box

    Code:
    Options:
    <select name="options">
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
    <option value="Option 4">Option 4</option>
    </select>
    TextAreas
    Code:
    <textarea name="fieldname" rows="4" cols="30"></textarea>

    Edited by L&#181;ke (Forum Moderator): Thread Moved From Website Designing. Please post in the correct section next time, Thanks .
    Last edited by Lµke; 22-02-2007 at 08:13 PM.


  2. #2
    Join Date
    Jan 2007
    Posts
    790
    Tokens
    3,429

    Latest Awards:

    Default

    Nice, i like the tut. Very helpful. +rep

  3. #3
    Join Date
    Nov 2006
    Posts
    7,395
    Tokens
    2,222

    Latest Awards:

    Default

    Just what I needed!!!

    +rep. This should get stickied
    Hi

  4. #4
    Join Date
    Jan 2007
    Posts
    790
    Tokens
    3,429

    Latest Awards:

    Default

    You could've just asked me for a contact form Danny, i have same one lol,

  5. #5
    Join Date
    Feb 2006
    Location
    Inside your PC
    Posts
    1,626
    Tokens
    0

    Latest Awards:

    Default

    Excellent +REP

  6. #6
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Is it possible that this could be moved to Web Tuts?


  7. #7
    Join Date
    Jan 2007
    Posts
    790
    Tokens
    3,429

    Latest Awards:

    Default

    Request it by a mod.

  8. #8
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    die ("Invalid Email Address"); 
    $badinput "<h2>Feedback was NOT submitted</h2>\n";
    echo 
    $badinput
    That wont be outputted.
    kinda quit.

  9. #9
    Join Date
    Nov 2006
    Location
    i live on my private island!
    Posts
    366
    Tokens
    0

    Default

    well done, i needed a contact form
    +rep
    (\_/)
    (o.o) This is Bunny. Copy Bunny to
    ('')('') help him achieve world domination.

  10. #10
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Oops i was goning to use badinput but it didn't work

    The contact form will still work though


Page 1 of 2 12 LastLast

Posting Permissions

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