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

Thread: Simple Form

  1. #1
    Join Date
    Apr 2009
    Posts
    4,289
    Tokens
    2,022
    Habbo
    iLogan

    Latest Awards:

    Default Simple Form

    Hey,

    Real nooby question... but, I need to make a simple competition page, where a user can type their answer and email address and it gets stored into a database or emailed to me,

    really don't want to use an online form builder, so something own server please

    Thanks!
    ex-hxl manager
    ex-event organizer
    ex-gfx designer
    ex-competition staff
    ex-content staff
    OFWGKΔ

  2. #2
    Join Date
    Apr 2009
    Posts
    4,289
    Tokens
    2,022
    Habbo
    iLogan

    Latest Awards:

    Default

    Any ideas?
    ex-hxl manager
    ex-event organizer
    ex-gfx designer
    ex-competition staff
    ex-content staff
    OFWGKΔ

  3. #3
    Join Date
    Jan 2008
    Location
    Wales
    Posts
    3,594
    Tokens
    1,387
    Habbo
    Skizzling

    Latest Awards:

    Default

    Customize this to your needs, should be pretty easy. Thanks to Moh for releasing this.
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Contact Form</title> 

    <style type="text/css" media="screen"> 
    fieldset { 
        margin-bottom: 3px; 


    legend { 
        font-weight: bold;     


    .good, .bad { 
        padding: 5px;     
        margin-bottom: 5px; 
        border: 1px solid; 


    .good { 
        background-color: #d9ffcf; 
        border-color: #ade5a3; 
        color: #1b801b; 


    .bad { 
        background-color: #ffcfcf; 
        border-color: #e5a3a3; 
        color: #801b1b; 

    </style> 
    </head> 

    <body> 

    <h1>Contact Form</h1> 

    <?php 

        $to_email 
    "removed"
        
    $subjects  = array( "Question""Complaint""Spotted an Error""Idea" ); 
        
    $hide_form false
         
        if( isset( 
    $_POST['submit'] ) ) { 
             
            
    $name        stripslashes$_POST['name'] ); 
            
    $subject    stripslashes$_POST['subject'] ); 
            
    $email        stripslashes$_POST['email'] ); 
            
    $message    stripslashes$_POST['message'] ); 
            
    $ip            $_SERVER['REMOTE_ADDR']; 
            
    $error        0
            
    $error_body    ""
             
             
            if( !
    $name ) { 
                
    $error_body .= "<li>You did not enter your name.</il>\n"
                
    $error++; 
            } 
            if( !
    in_array$subject$subjects ) ) { 
                
    $error_body .= "<li>Invalid Subject.</il>\n"
                
    $error++; 
            } 
            if( !
    $email ) { 
                
    $error_body .= "<li>You did not enter an email address.</il>\n"
                
    $error++; 
            } 
            if( !
    preg_match("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$^"$email ) and $email ) { 
                
    $error_body .= "<li>You entered an invalid email address.</il>\n"
                
    $error++; 
            } 
            if( !
    $message ) { 
                
    $error_body .= "<li>You did not enter a message.</il>\n"
                
    $error++; 
            } 
             
            if( 
    $error ) { 
                 
                echo 
    "<div class=\"bad\">\n"
                echo 
    "<strong>The following " . ( ( $error ) ? "errors" "error" ) . " occurred</strong>:\n"
                echo 
    "<ul>\n"
                echo 
    $error_body
                echo 
    "</ul>\n"
                echo 
    "</div>\n"
                 
            } else { 
                 
                echo 
    "<div class=\"good\">\n"
                echo 
    "Thank you {$name} for your message.\n"
                echo 
    "</div>\n"
                 
                
    $message nl2br$message ); 
                         
                
    $body .= "----------------------------------\n"
                
    $body .= "<p>\n"
                
    $body .= "<strong>Name</strong>: {$name}<br />\n"
                
    $body .= "<strong>Subject</strong>: {$subject}<br />\n"
                
    $body .= "<strong>Email Address</strong>: {$email}<br />\n"
                
    $body .= "<strong>Message</strong>: {$message}<br />\n"
                
    $body .= "<strong>IP Address</strong>: {$ip}<br />\n";             
                
    $body .= "</p>\n"
                
    $body .= "----------------------------------\n"

                
    $headers  "MIME-Version: 1.0" "\r\n"
                
    $headers .= "Content-type: text/html; charset=iso-8859-1" "\r\n"
                
    $headers .= "From: {$name} <{$email}>" "\r\n"
                 
                
    mail$to_email"Contact Form: {$subject}"$body$headers );     
                 
                
    $hide_form true
                             
            } 
             
        } 

    ?> 
     
    <?php 
        
    if( !$hide_form ) { 
    ?> 
    <form method="post"> 

        <fieldset> 
            <legend>Name</legend> 
            <input type="text" name="name" value="<?php echo $name?>" /> 
        </fieldset> 
         
        <fieldset> 
            <legend>Email Address</legend> 
            <input type="text" name="email" value="<?php echo $email?>" /> 
        </fieldset> 
         
        <fieldset> 
            <legend>Subject</legend> 
            <select name="subject"> 
                <?php 
                 
                    
    foreach( $subjects as $i ) { 
                        if( 
    $i == $subject ) { 
                            echo 
    "<option selected=\"selected\">{$i}</option>\n"
                        } else { 
                            echo 
    "<option>{$i}</option>\n"
                        } 
                    } 
                 
                
    ?> 
            </select> 
        </fieldset> 

        <fieldset> 
            <legend>Message</legend> 
            <textarea name="message" rows="10" cols="50"><?php echo $message?></textarea> 
        </fieldset> 
         
        <input type="submit" name="submit" value="Send" /> 
         
    </form> 
    <?php 
        

    ?> 
     

    </body> 
    </html>

  4. #4
    Join Date
    Apr 2009
    Posts
    4,289
    Tokens
    2,022
    Habbo
    iLogan

    Latest Awards:

    Default

    tysm!!! xox
    ex-hxl manager
    ex-event organizer
    ex-gfx designer
    ex-competition staff
    ex-content staff
    OFWGKΔ

Posting Permissions

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