Page 1 of 1

php registrationform code

Posted: Thu Sep 24, 2015 8:52 am
by WilliamHerr
Why is it important to get the best mattress bed? As we know, to relax is a crucial part of our daily lifestyle. Solely with the correct mattress will you get the chance to encounter the promises of a great rest. Resting on the wrong memory foam will only provide you a nighttime of uncomfortableness, a bad temper every early morning, and joint aches and pains.

Lets face it everybody requirements a best mattress 2015 to rest on. Even although its the mattress that issues the most, the mattress body also gives you the added advantage and that is it appears good sufficient that you want to be in mattress all day lengthy. These days, you do not need to go out to purchase a bed frame and mattress. You can buy both one or each with online shopping. Provides found on internet sites are unbelievable if you know precisely what you are searching for. Moreover, you can study on the kinds of mattress frames that you want alongside with the mattresses. Some web sites have the very best deals for you if you buy both the bed frame and mattress.

For a queen mattress, you should purchase higher quality queen mattress as well. Go to local queen mattress Sydney showrooms and discover a appropriate mattress for your mattress. Don't buy cheap mattresses simply because they sag after a couple of years.

<center>Image</center>

If somebody will be sleeping with you, bring them along. Above all, the best king size mattress should support your backbone and ought to not interfere with your pressure points.

Practice good health and safety in the function and house atmosphere - Raise with the knees and bend the back is a well recognized phrase. And it works! Practice this more frequently and you can avoid nasty injuries. Also don't be frightened to inquire for help lifting somethings if they are too hefty.

The typical person tends to move about 40 to 60 times whilst sleeping at evening. Think about the dimension of the mattress especially when you share it with somebody else. Your very best wager would have to be both a king dimension or a queen size mattress if you are an extremely fidgety throughout sleep or if you rest with a partner.

Read more: brentwood mattress reviews

Hungry Mother State Park is a picturesque forested park that is filled with recreational opportunities and a great deal of room to unwind. Whether you are searching for a holiday location or merely a weekend escape, Virginia's Hungry Mom Condition Park can satisfy your requirements.

15. In the 2000's foam mattress cores airbeds, waterbeds and higher-tech adjustable sleep sets were the rage. Comfortable pillow leading mattresses and single-sided no-flip mattresses grew to become accessible on the market.

Re: php registrationform code

Posted: Thu Sep 24, 2015 12:40 pm
by Strider64
I modified your script a little ... well quite a bit. :D

I stylized the form with CSS, it pretty simple once you get the hang of CSS.

Here's the script:

Code: Select all

<?php
    $check = FALSE;
    
    function check_for_blanks(array $data) {
        /* If any value is empty this we know we have a blank field */
        foreach ($data as $key => $value) {
            if (empty($value)) {
                return TRUE;
            }
        }
        return FALSE; // Return false if all fields are entered:
    }
    
    /* Assigned Submit button a variable */
    $submit = filter_input(INPUT_POST, 'submit', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    
    /* Don't use $_SERVER better to use $_POST or in this case filter_input */
    if (isset($submit) && $submit === 'Register') {
        $first_name = filter_input(INPUT_POST, 'first_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
        $last_name = filter_input(INPUT_POST, 'last_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
        $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
        $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
        $confirm = filter_input(INPUT_POST, 'confirm', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
        
        /* Make sure the user can't add spaces to `bypass` the registeration form */
        $data['first_name'] = isset($first_name) ? trim($first_name) : '';
        $data['last_name'] = isset($last_name) ? trim($last_name) : '';
        $data['email'] = isset($email) ? trim($email) : '';
        $data['password'] = isset($password) ? trim($password) : '';
        $data['confirm'] = isset($confirm) ? trim($confirm) : '';
        
        $check = check_for_blanks($data);
        
        /* If condition is TRUE set appropiate error message */
        if ($check) {
            $error['blank'] = 'All input fields must be filled in!';
        }
        
        /*
         * More Validation script(s) should go here.....
         */
        
        /* If condition is FALSE then save to database table */
        if (!$check) {
           /* Save to Database Table */
        }
        
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>A Simple Registration Form</title>
        <style>
            form#register {
                display: block;
                width: 100%;
                max-width: 400px;
                height: 100%;
                min-height: 250px;
                max-height: 500px;
                background-color: lightblue;
                padding: 20px;
                margin: 20px auto;
            }
            form#register label {
                float: left;
                display: block;
                width: 100%;
                max-width: 160px;
                height: 25px;
                line-height: 25px;
                text-align: right;
                padding-right: 10px;
                margin: 5px 0;
            }
            form#register input {
                clear: right;
                display: block;
                width: 100%;
                max-width: 200px;
                height: 25px;
                line-height: 25px;
                margin: 5px 0;
            }
            form#register input[type=submit] {
                border: none;
                outline: none;
                cursor: pointer;
                float: right;
                display: block;
                width: 100px;
                height: 35px;
                font-family: Arial, Helvetica, sans-serif;
                font-size: 1.2rem;
                color: #fff;
                background-color: darkblue;
                margin: 10px 30px 10px;
            }
            form#register input[type=submit]:hover {
                background-color: orange;
            }
        </style>
    </head>
    <body>
        <?php 
            /* A good place to display the error message(s) */
        ?>
        <form id="register" action="" method="post">
            <label>First Name</label>
            <input type="text" name="first_name" value="<?php echo ($first_name) ? $first_name : NULL; ?>">
            <label>Last Name</label>
            <input type="text" name="last_name" value="<?php echo ($last_name) ? $last_name : NULL; ?>">
            <label>Email</label>
            <input type="email" name="email" value="<?php echo ($email) ? $email : NULL; ?>">
            <label>Password</label>
            <!-- Not Good Practice to echo password back in a form -->
            <input type="password" name="password">
            <label>Confirm Password</label>
            <!-- Not Good Practice to echo password back in a form -->
            <input type="password" name="confirm">
            <input type="submit" name="submit" value="Register">
        </form>
    </body>
</html>
I didn't do all the validation code and I didn't do any of the database code, for I figured it would be more worthwhile for you to do that. Though I'm sure others here will help you if you get stuck. HTH John

Re: php registrationform code

Posted: Thu Sep 24, 2015 5:09 pm
by Christopher
You could simplify with functions even further:

Code: Select all

<?php
    $blank = array();
    
    function get_post($field, $filter=FILTER_SANITIZE_FULL_SPECIAL_CHARS, $default='') {
        $value = filter_input(INPUT_POST, $field, $filter);
        $value = isset($value) ? trim($value) : '';
    }

    function check_for_blanks(array $data) {
        $blank = array();
        /* If any value is empty this we know we have a blank field */
        foreach ($data as $key => $value) {
            if (empty($value)) {
                $blank[$key] = $key;
            }
        }
        return $blank; // Return false if all fields are entered:
    }
    
    /* Assigned Submit button a variable */
    $submit = get_post('submit', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    
    /* Don't use $_SERVER better to use $_POST or in this case filter_input */
    if (isset($submit) && $submit === 'Register') {
       
        /* Make sure the user can't add spaces to `bypass` the registeration form */
        $data['first_name'] = get_post('first_name');
        $data['last_name'] = get_post('last_name');
        $data['email'] = get_post('email');
        $data['password'] = get_post('password');
        $data['confirm'] = get_post('confirm');
        
        $blank = check_for_blanks($data);
        
        /* If condition is TRUE set appropiate error message */
        if ($blank) {
            $error['blank'] = 'Input fields ' . implode(', ', $blank) . ' must be filled in!';
        }