Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Students should be able to work with form in PHP and how to process form data securely and properly using some sanitizing function as

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Objectives: Students should be able to work with form in PHP and how to process form data securely and properly using some sanitizing function as well as function preg_match(). We will cover regular expression in the next class. Part 1: Warm-Up Create a simple form with at least 2 fields: Username and Password Create a separate file to process and validate input from the form. Then include the file on top of the form using functions include or require. Save the json file from BB to an appropriate folder in the project Part 2: Log-in form Requirements: Form: There should be at least 2 input fields for username and password . Given a json file as a database in which there are several usernames and passwords. Student must: Write PHP code to access data in the json file. Then, decode the json string to either a json object or an associative array . After the user submitted the form, students must: o sanitize the inputs. Write a PHP function to retum Sanitized data check if there is a match with one username and one password from the database. If there is no match, print out an error message to user on the form o If it is a match create an URL link with username as a URL.parameter then redirect the user to a welcome page where it displays: Welcome username Hint: Use S_GET array for this step. Part 3: Sign-up form The idea is the same as part 2. Students must: Have a form that contains at least 2 input fields: usemame and password. The crror message or success message are hidden before the user click submit buttons . You should apply some rules for the format of either username or password You can search google for the pattern you'd like to have on your website User preg_match() function to match the pattern and the form data There should be messages: Error message for empty field. Error message if there is invalid username password o If there is no error, display a success message saying that the user signed up successfully. If the new account is valid, append the new account to the database: o Read the json file and decode to an associative array. o Use function array_push() to append the new account to the array. NOTE: the new account should be in a small array with the same structure as the decoded array. o Use function file_put_contents() to write the new json string into the original file. Objectives: Students should be able to work with form in PHP and how to process form data securely and properly using some sanitizing function as well as function preg_match(). We will cover regular expression in the next class. Part 1: Warm-Up Create a simple form with at least 2 fields: Username and Password. Create a separate file to process and validate input from the form. Then include the file on top of the form using functions include or require. Save the json file from BB to an appropriate folder in the project. Part 2: Log-in form Requirements: Form: o There should be at least 2 input fields for username and password. Given a json file as a database in which there are several usernames and passwords. Student must: o Write PHP code to access data in the json file. o Then, decode the json string to either a json object or an associative array. After the user submitted the form, students must: o sanitize the inputs. Write a PHP function to return sanitized data. o check if there is a match with one username and one password from the database. o If there is no match, print out an error message to user on the form. o If it is a match, create an URL link with username as a URL parameter then redirect the user to a welcome page where it displays: Welcome Hint: Use $_GET array for this step. Part 3: Sign-up form The idea is the same as part 2. Students must: Have a form that contains at least 2 input fields: username and password. The error message or success message are hidden before the user click submit buttons. You should apply some rules for the format of either username or password. You can search google for the pattern you'd like to have on your website o User preg_match() function to match the pattern and the form data There should be messages: Error message for empty field. Error message if there is invalid username/password o If there is no error, display a success message saying that the user signed up successfully. If the new account is valid, append the new account to the database: o Read the json file and decode to an associative array. o Use function array_push() to append the new account to the array. NOTE: the new account should be in a small array with the same structure as the decoded array. o Use function file_put_contents() to write the new json string into the original file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago