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 18
  1. #1
    Join Date
    Jun 2005
    Location
    Manchester
    Posts
    3,187
    Tokens
    0

    Latest Awards:

    Default || Basic PHP Form ||

    Hi.

    For my second PHP tutorial i'm going to tell you how to code a simple form with a simple PHP code.

    This tutorial is written and copyright to me

    Here we go:

    Well first the easy bit.

    Creating the forms layout. and here we go.

    HTML Code:
    <form action="mail.php" method="post">
    Name <input type="text" name="name"><br/>
    Email addess <input type="text" name="email"><br/>
    Message<br/>
    <textarea name="message" cols="40" rows="5"></textarea><br/>
    <input type="submit" value="send"><br/>
    </form>
    
    
    Now i'm sure your all familiar with a simple form layout so i kept it simple.

    Now you must name the PHP file mail.php if you don't want to change anything on the form layout.

    Heres the PHP code i'll explain in the PHP code so it doesn't get confusing.

    PHP Code:

    <?php

    //variables (You can change the Variables)

    $youremail "[email protected]";
    // your email address

    $subject "Contact";
    // the subject of the email

    $formsent "formsent.php";
    // The re-direct page in which it can say Form sent

    // Don't change anything else on this script

    if($email == ""){
    ?>
    No email address added. Please go back.<br/>
    <?php
    }elseif($name == ""){
    ?>
    No name added. Please go back.<br/>
    <?php
    }elseif($message == ""){
    ?>
    No message added. Please go back.<br/>
    <?php
    }else{

    $msg ereg_replace("\\\'""'"$message);
    $msg ereg_replace('\\\"'"\""$msg);
    $message1 "from: $name\nemail: $email\nmessage:\n$msg1";

    mail($youremail$subject$msg"From: $email\r\nReply-to: $email\r\n");
    ?>
    <meta http-equiv="refresh" content="0; url=<?echo $formsent;?>"">
    <?php
    }
    ?>
    Now the bits with // are explaining what to do, after reading many PHP tutorials for CMS's i've seen people do this.

    I took around 20 minutes last night creating this form as i ran into a few problems, this should work if not please contact me

    - Dan

  2. #2
    Join Date
    Aug 2005
    Location
    Newcastle
    Posts
    1,417
    Tokens
    0

    Latest Awards:

    Default

    Nice! , I cant see any errors as far as my eye's.

    Great Tut, Im sure many user's will use this.

    Keep the tutorial Frenzy coming! ^_^



  3. #3
    Join Date
    Jun 2005
    Location
    Manchester
    Posts
    3,187
    Tokens
    0

    Latest Awards:

    Default

    LOL, i will do don't worry dude, i got all these saved on my desktop to put onto my site

    - Dan

  4. #4
    Join Date
    May 2005
    Location
    Cornwall
    Posts
    3,590
    Tokens
    2,900
    Habbo
    Feyod

    Latest Awards:

    Default

    I see a new Tutorial forum coming "Raremandans Tutorial's" :rolleyes:

    Thank's for the new Tut :-) another one i will use :'D
    Occasionally visit and have a nose.

  5. #5
    Join Date
    Aug 2005
    Location
    Newcastle
    Posts
    1,417
    Tokens
    0

    Latest Awards:

    Default

    I Forgot about my old tutorial on here ^_^ You can use that on your site if you wish Its a bit out-dated now Rofl.

    http://www.habboxforum.com/showthread.php?t=79006



    Peace Dudes/Dudettes



  6. #6
    Join Date
    Jun 2005
    Location
    Manchester
    Posts
    3,187
    Tokens
    0

    Latest Awards:

    Default

    Cheers lol

    I'm happy writing them as long as people need them, As i love learning new things

    - Dan

  7. #7
    Join Date
    Feb 2005
    Posts
    2,503
    Tokens
    0

    Latest Awards:

    Default

    Very good ill be using it + rep
    Edit: Iam very sorry but it says "You must spread some Reputation around before giving it to Raremandan again." sorry

  8. #8
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    To check if a variable is empty its better to use:
    PHP Code:
    if (!$post) {
    echo 
    "You havent filled in this field";

    also why do you keep ending the <? ?> tags :S to write something just use echo Its abit long winded but well construced.

    Instead of using a meta redirection the easier way in php is to do:
    PHP Code:
    header("Location: formsent.php"); 

  9. #9
    Join Date
    Apr 2005
    Posts
    4,963
    Tokens
    0

    Latest Awards:

    Default

    Just what i needed
    But the test email thingys are taking ages to come >

  10. #10
    [N] Guest

    Default

    Hey keep it up

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
  •