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 9 of 9

Thread: PHP FAQ

  1. #1
    Join Date
    Jul 2004
    Location
    Habbo Newsie Office
    Posts
    352
    Tokens
    0

    Default PHP FAQ

    Hi everyone! I wrote down a Form Contact with 2 page to send it to a email!

    Here the first page Form!

    <form action="contactme.php" mehod="post">
    <table border="1" cellspacing="1" width="100%" id="AutoNumber20" style="border-width: 0">
    <tr>
    <td width="10%" style="border-style: none; border-width: medium"><font face="Verdana" size="1" color="#ECECFF">Habbo Name:</font></td>
    <td width="1%" style="border-style: none; border-width: medium">&nbsp;</td>
    <td width="89%" style="border-style: none; border-width: medium">
    <input type="text" name="name" size="20"></td>
    </tr>
    <tr>
    <td width="10%" style="border-style: none; border-width: medium"><font face="Verdana" size="1" color="#ECECFF">Habbo Hotel:</font></td>
    <td width="1%" style="border-style: none; border-width: medium">&nbsp;</td>
    <td width="89%" style="border-style: none; border-width: medium">
    <font face="Verdana" size="1"><select size="1" name="Hotel">
    <option selected>-- Select One --</option>
    <option>Habbhotel.Com</option>
    <option>HabboHotel.Co.Uk</option>
    <option>HabboHotel.Ca</option>
    <option>Habbohotel.Au.Com</option>
    <option>Other</option>
    </select></font></td>
    </tr>
    <tr>
    <td width="10%" style="border-style: none; border-width: medium"><font face="Verdana" size="1" color="#ECECFF">Email:</font></td>
    <td width="1%" style="border-style: none; border-width: medium">&nbsp;</td>
    <td width="89%" style="border-style: none; border-width: medium">
    <input type="text" name="Email" size="20"></td>
    </tr>
    <tr>
    <td width="10%" style="border-style: none; border-width: medium"><font face="Verdana" size="1" color="#ECECFF">Subject:</font></td>
    <td width="1%" style="border-style: none; border-width: medium">&nbsp;</td>
    <td width="89%" style="border-style: none; border-width: medium">
    <input type="text" name="Subject" size="20"></td>
    </tr>
    <tr>
    <td width="10%" style="border-style: none; border-width: medium"><font face="Verdana" size="1" color="#ECECFF">Message:</font></td>
    <td width="1%" style="border-style: none; border-width: medium">&nbsp;</td>
    <td width="89%" style="border-style: none; border-width: medium">
    <textarea rows="6" name="comments" cols="29"></textarea></td>
    </tr>
    </table>
    <p><input type="submit" value="Submit" name="B1"></p>
    </form>
    And here the Contactme.php!

    <?PHP
    $to = "[email protected]";
    $re = "Contact Us";
    $hotel = $Hotel;
    $mail = $Email;
    $msg = $comments;
    $name = $name;
    $sub = $Subject;
    mail($to,$name,$hotel,$mail,$msg);
    ?>
    Unfortunotly its doesnt bring me all the information! That i want and i believe my mistake will be on contactme.php page! But why and how?

    BTW i am new at php! I just learn how today how to save a page in php with frontpage! But i am a fast learning and since a i do a lot of c++ and i am expert at it! I understood the fact that they were variable giveway + mail is what will be find in the mail!
    ABC = Alway Be Careful
    Check out!
    Habbo Newsie

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

    Latest Awards:

    Default

    ok a few problems

    First off to get the varible from the forum. use.

    $name = $_POST['name'];


    if the subjcets name was name. athogh teh varible itslef could be anything.

    so all of your varibles would be


    $hotel = $_POST['Hotel'];
    $email = $_POST['name'];
    $name = $_POST['Email];
    $subject = $_POST['subject'];
    $comments = $_POST['comments'];

    then you woul combine the data in to a singel varible to be the message

    $mess = "$name ( $email ) \n on the $hotel Hotel. \n \n sent: \n $comments";


    as an exsample.

    the $name vearibela nd others get convrted to the other vaules.

    the next problme is the mail function as its layed out like ths.
    aka, email(resipiant) is fist bit, email subject is next, the message next, then if you want who its from.
    the message varible should be set with data from other varibles.
    mail ($Email, $Subject, $msg, $From);

    so a basic email thing would be

    PHP Code:
    <?php
    $hotel 
    $_POST['Hotel'];
    $email $_POST['name'];
    $name $_POST['Email];
    $subject = $_POST['
    subject'];
    $comments = $_POST['
    comments'];

    $mess = "$name ( $email ) \n on the $hotel Hotel. \n \n with the subject: $subject \n sent: \n $comments";

    $to = "[email protected]";
    $from = "From: [email protected] \r\n";

    mail ($to, $subject, $mess, $from);
    ?>
    for eg.

    Athogh if you want to stop it bening spammed (aka this wayit would send an emial if ist viewed directly in the browers. you could ad a simple mesuer

    PHP Code:
    <?php
    if ($_SERVER['REQUEST_METHOD'] != 'GET'){

    $hotel $_POST['Hotel'];
    $email $_POST['name'];
    $name $_POST['Email];
    $subject = $_POST['
    subject'];
    $comments = $_POST['
    comments'];

    $mess = "$name ( $email ) \n on the $hotel Hotel. \n \n with the subject: $subject \n sent: \n $comments";

    $to = "[email protected]";
    $from = "From: [email protected] \r\n";

    mail ($to, $subject, $mess, $from);

    }
    else
    {
    echo "You may not view this page directly";
    }
    ?>

  3. #3
    Join Date
    Jul 2004
    Location
    Habbo Newsie Office
    Posts
    352
    Tokens
    0

    Default

    hmm its seem great! And now no more code problem except that! ITs send me a message like this


    ( )
    on the Hotel.

    with the subject:
    sent:

    So they his where the variable are gone? its doesnt gave the name, the email the hotel, the subject and the message! and here the script!

    <?php
    $hotel = $_POST['Hotel'];
    $email = $_POST['name'];
    $name = $_POST['Email'];
    $subject = $_POST['subject'];
    $comments = $_POST['comments'];

    $mess = "$name ( $email ) \n on the $hotel Hotel. \n \n with the subject: $subject \n sent: \n $comments";

    $to = "[email protected]";

    mail ($to, $subject, $mess, $from);
    $from = "Contact Page";

    ?>
    so its seem great exept this line in red!Why? but thx for the rest of it!
    ABC = Alway Be Careful
    Check out!
    Habbo Newsie

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

    Latest Awards:

    Default

    ok. i may have made a few mistakes, as name and email have been mixed up.

    In the form itself. Each input has a name

    ( name="whatever")

    then the varibles are tacken by this

    $_POST['whatever];

    the orgnal name, being where whatever is.
    check all that corisponds correctly

    aslo another problem i noticed was

    PHP Code:
    $email $_POST['name'];
    $name $_POST['Email']; 
    should be
    PHP Code:
    $name$_POST['name'];
    $email $_POST['Email']; 
    aslo some server configrtiosn wont like the short cut so try this

    PHP Code:
    $mess "".$name."  ( ".$email."  ) \n on the ".$hotel." Hotel. \n \n with the subject: ".$subject."  \n sent: \n ".$comments.""

  5. #5
    Join Date
    Jul 2004
    Location
    Habbo Newsie Office
    Posts
    352
    Tokens
    0

    Default

    still showing no message why :S

    Here i took my first code from this::

    Step 1:: Make a page called contact.php and paste this code into it.

    <form action="contactme.php" mehod="post">
    <p align="center">
    <b><font size="2" face="Verdana">Name: <input type="text" name"username" size="30"/>
    <br>
    <br>
    Email: <input type="text" name="useraddr" size="30">
    <br>
    <br>
    Message: <textarea name="comments" cols="30" rows="5"> </textarea>
    <br>
    <br>
    <input type="submit" value="Send Form"> </font></p>
    </form></b>
    Step 2:: Make a new page and paste the code below into it and name it contactme.php

    <?PHP
    #Where you want the email to go
    $to = "[email protected]";

    #subject of the message, change this
    $re = "Feedbackfromcontactpage";

    #message from the feedback form, don't touch this
    $msg = $comments;

    #send the mail, don't edit this
    mail($to,$re,$msg);
    ?>
    And use to work really great but i wan to add some field so i did them! but should i just send it by mail($to,$etc....)
    Last edited by Jseb; 14-04-2005 at 09:12 PM.
    ABC = Alway Be Careful
    Check out!
    Habbo Newsie

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

    Latest Awards:

    Default

    i noticed an error, heres a redue if the code

    PHP Code:
    <?php
    if ($_SERVER['REQUEST_METHOD'] != 'GET'){

    $hotel $_POST['Hotel'];
    $name$_POST['name'];
    $email$_POST['Email'];
    $subject $_POST['subject'];
    $comments $_POST['comments'];

     
    $mess "".$name."  ( ".$email."  ) \n on the ".$hotel." Hotel. \n \n with the subject: ".$subject."  \n sent: \n ".$comments.""

    $to "[email protected]";
    $from "From: [email protected] \r\n";

    mail ($to$subject$mess$from);

    }
    else
    {
    echo 
    "You may not view this page directly";
    }
    ?>

  7. #7
    Join Date
    Jul 2004
    Location
    Habbo Newsie Office
    Posts
    352
    Tokens
    0

    Default

    Hmm k well that newest thing i just well put it on and to see and all my thing were fill in however its just gave me the access of echo thing at the end else! didnt do the rigth one! why :S
    ABC = Alway Be Careful
    Check out!
    Habbo Newsie

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

    Latest Awards:

    Default

    i would recomend to one i used on digital designs


    www.lp-revolution.com/digitaldesigns

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

  9. #9
    Join Date
    Jul 2004
    Location
    Habbo Newsie Office
    Posts
    352
    Tokens
    0

    Default

    And what script did u use? or is there a way so that i can get a scritp with a working form!
    ABC = Alway Be Careful
    Check out!
    Habbo Newsie

Posting Permissions

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