Question

In: Computer Science

PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML...

PHP Question -

Subject: PHP File Handling and Uploads

INSTRUCTIONS:

Objective:

• Create a sticky HTML form.
• Submit form for processing.
• Sanitize and validate form data.
• Upload a profile image.
• Add a record to a text file.
• Display form results with content from another text file and the uploaded image.

Description:

This assignment deals with file management. It requires the use of 3 new files and 1 new directory. You will create the new file-uploads.php file, a new membership.txt file to record form data, a poem.txt file to store a "poem" of your choice and a new images directory. All information in this assignment is processed and displayed using the file-uploads.php page. There are no redirects.

You will need to build a form to upload user images and access a couple of files on the server. The form will be processed and validated. The sanitized and validated form information will be saved to a text file (membership.txt) you create on the server. Once the form has been processed and the image uploaded to the new images directory, you will not redirect the user to a new page to display the results as specified. Instead, you will code the existing page to process the form, including the image upload, then display the formatted information (instead of the form) along with some information from a text file (poem.txt) you create.

Requirements:

Create a PHP page named file-uploads.php with a form using the following field controls:

• Single line text box for the user's first name.
• Single line text box for the user's last name.
• Single line text field for email.
• Single line text field for password.
• Single line text field for password verify.
• Add a file control to the form to upload a profile image file.

Process the form text information.

• Upon form submission, sanitize and validate the text information.
• If the information is valid, create a new lowercase username with the first initial of the first name concatenated with the last name. (IE: sherd)
• Set the first letter of the first and last names to uppercase then concatenate the first name and last name into one field with a separation space between the names.
• Append the membership.txt file with the user's name, email, password and new username.

Process the image upload.

• Add validation to make sure the image file is an appropriate image type and size is 100KB or less.
• If the image passes validation, check to see if it already exists. If so, display an error and return the form to the user..
• If the image file doesn't exist, upload the image to the server.

Style and prep the HTML in both pages.

• Include the functions file.
• Wrap the page output in your header and footer.
• Utilize the Bootstrap framework to style your page contents.

Add form processing to the file to sanitize and validate the form submission. Include sticky form fields and error messages.

• Text fields must be present and convert any HTML tags present using htmlspecialchars().
• Text fields and passwords must be trimmed using trim().
• Email must validate using preg_match().
• Convert all names in name field to first letter uppercase.
• All form fields must be checked for content. Any missing content should trigger the form to be redisplayed to the user with a warning to provide acceptable information.

Solutions

Expert Solution

file-uploads.php-

<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <form method='POST'> <h2>Please input your first name:</h2> <input type="text" name="Firstname">

<h2> Please input your last name</h2>

<input type ="text" name="Last name">

<h2>Please input your Email:</h2> <input type="text" name="Email">

<h2>Please input your Password:</h2> <input type="password" name="password">

<h2>Please input your confirm password:</h2> <input type="password" name="Confirm Password">

<h2>Please upload profile image:</h2> <input type="file" name="ProfileImage" id="ProfileImage">

  1. <input type="submit" value="ProfileImage" name="submit">

</form> <?php //Retrieve name from query string and store to a local variable $name = $_POST['name']; echo "<h3> Hello $name </h3>"; ?> </body> </html>


Related Solutions

PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML form. • Submit form for processing. • Sanitize and validate form data. • Upload a profile image. • Add a record to a text file. • Display form results with content from another text file and the uploaded image. Description: This assignment deals with file management. It requires the use of 3 new files and 1 new directory. You will create the new file-uploads.php...
PHP Question: Subject: Functions and Arrays. INSTRUCTIONS: Objective: • Write functions. • Use server-side includes. •...
PHP Question: Subject: Functions and Arrays. INSTRUCTIONS: Objective: • Write functions. • Use server-side includes. • Create and utilize a numeric array. • Create and utilize an associative array. Requirements: Create a script file called functions.php, where you will be adding functions. priceCalc() function: • 2 parameters: price and quantity. • Create a numeric array of discounts with the following values: 0,0,.05,.1,.2,.25. • Get the discount percent from the array using the quantity as the index. If the quantity is...
PHP Question: Subject: Managing Persistence. Objective: • Create a login script. • Strengthen passwords. • Authenticate...
PHP Question: Subject: Managing Persistence. Objective: • Create a login script. • Strengthen passwords. • Authenticate users. • Create sessions. • Create cookies. • Manage persistence. Description: All dynamic sites need a way to manage access to resources. Many dynamic sites use back-end databases that can contain sensitive information that needs to be securely managed. At the same time, sites want to be inviting to guests. Managing the access to sensitive information is a critical function. Requirements: Update site for...
Please create a PHP action codes for the HTML CODE provided below. <!DOCTYPE html> <html> <head>...
Please create a PHP action codes for the HTML CODE provided below. <!DOCTYPE html> <html> <head> <title> Project for keeping all your input </title> </head> <body> <h1>Welcome to this Web Based Test!!!</h1> <p>Please answer the following questions:</p> <hr/> <form action="" method="post"> Name: <input type="text" name="name" value=""> <font color=red>*</font><br/><br/> E-mail: <input type="text" name="email" value=""> <font color=red>*</font><br> <hr/> Choose your major area of study: <select name="major"> <option value="Digital Media" >Digital Media</option> <option value="Software" >Software</option> <option value="Security" >Security</option> <option value="Business" >Business</option> <option value="Other"...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)    3. Assign your name as a string value into the variable labeled myName (Unit Objective 2)    4. Assign 53870 numeric value into the variable named randomNumber (Unit Objective 2) 5. ssign the name of the web browser and operating system of the...
how to read a csv file in php and make a html table? I can't use...
how to read a csv file in php and make a html table? I can't use the PHP function fgetcsv. I can use explode. I can't put a php inside a php. Acme,Walmart,Ross,BJs,Target,Marshalls,Foot Locker,Giant,Charming Charlie 142,160,28,10,5,3,60,0.28,3167 175,180,18,8,4,1,12,0.43,4033 129,132,13,6,3,1,41,0.33,1471 138,140,17,7,3,1,22,0.46,3204 232,240,25,8,4,3,5,2.05,3613 135,140,18,7,4,3,9,0.57,3028 150,160,20,8,4,3,18,4.00,3131 207,225,22,8,4,2,16,2.22,5158 271,285,30,10,5,2,30,0.53,5702 89,90,10,5,3,1,43,0.30,2054 153,157,22,8,3,3,18,0.38,4127 87,90,16,7,3,1,50,0.65,1445 234,238,25,8,4,2,2,1.61,2087 106,116,20,8,4,1,13,0.22,2818 175,180,22,8,4,2,15,2.06,3917 165,170,17,8,4,2,33,0.46,2220 166,170,23,9,4,2,37,0.27,3498 136,140,19,7,3,1,22,0.63,3607 <!DOCTYPE html> <html> <head>    <meta charset="utf-8">    <title>Stores</title>    <link rel="stylesheet" href="style.css"> </head> <body> <h1>Stores</h1> <?php <table> <tr> <th>Acme</th> <th>Walmart</th> <th>Ross</th> <th>BJs</th> <th>Target</th> <th>Marshalls</th> <th>Foot Locker</th>...
- Create an html form (bank form) and the PHP code with 2 accounts with options...
- Create an html form (bank form) and the PHP code with 2 accounts with options to transfer, deposit or withdraw money.
How to do in C++ HTML Converter Create a program that reads an HTML file and...
How to do in C++ HTML Converter Create a program that reads an HTML file and converts it to plain text. Console HTML Converter Grocery List * Eggs * Milk * Butter Specifications Your instructor should provide an HTML file named groceries.html that contains these HTML tags: <h1>Grocery List</h1> <ul>     <li>Eggs</li>     <li>Milk</li>     <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to retrieve the information from the database on to my localhost. Please post a php/html code that will create a search page and return the data from my phpmyadmin database. The 3 items I have on the database are first_name, last_name and birth_day.
Create a web page using PHP and HTML that contains a list of movie names available...
Create a web page using PHP and HTML that contains a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required. 2) The rental price for each movie ranges between $1.99 to $7.99. • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT