Time spent: 7 hours spent in total
The following required functionality is completed:
- Create a Users Table
- Define a table "users" for columns id, firstname, lastname, email, username, createdAt
- Create a Page with an HTML Form
- with text inputs: first_name, last_name, email, username
- submits to: itself ("public/register.php")
- Detect when the form is submitted
- If "/public/register.php" is loaded directly, it should display the form.
- If the form was submitted, it should retrieve the form data.
- Validate form data
- Validate the presence of all form values.
- Validate that no values are longer than 255 characters.
- Validate that first_name and last_name have at least 2 characters.
- Validate that username has at least 8 characters.
- Validate that email contains a "@".
- Display form errors if any validations fail.
- Do not submit the data to the database.
- Redisplay the form with the submitted values filled in.
- Report all errors as a list above the form.
- Submit successfully-validated form values to the database.
- Write an SQL statement which will insert a new record into the globitek.users table using the submitted form values.
- Redirect the user to a confirmation page.
- Redirect the user to the new page.
- Sanitize all dynamic output for HTML.
The following advanced user stories are optional:
-
Bonus 1: Validate that form values contain only whitelisted characters.
- first_name, last_name: letters, spaces, symbols: - , . '
- username: letters, numbers, symbols: _
- email: letters, numbers, symbols: _ @ .
-
Bonus 2: Validate the uniqueness of the username.
Here's a walkthrough of implemented user stories:
GIF created with Peek.
Describe any challenges encountered while building the app.
Had a lot of trouble setting up PHP and MySQL on my Ubuntu computer. Also had issues with duplicate functions because I didn't know they were written already (is_post_request() specifically).
Copyright [2017] [Jocelyn Tran]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.