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

90.2K

Verified Solution

Question

Programming

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 theuploaded image.

Description:

This assignment deals with file management. It requires the useof 3 new files and 1 new directory. You will create the newfile-uploads.php file, a new membership.txt file to record formdata, a poem.txt file to store a \"poem\" of your choice and a newimages directory. All information in this assignment is processedand displayed using the file-uploads.php page. There are noredirects.

You will need to build a form to upload user images and access acouple of files on the server. The form will be processed andvalidated. The sanitized and validated form information will besaved to a text file (membership.txt) you create on the server.Once the form has been processed and the image uploaded to the newimages directory, you will not redirect the user to a new page todisplay the results as specified. Instead, you will code theexisting page to process the form, including the image upload, thendisplay the formatted information (instead of the form) along withsome information from a text file (poem.txt) you create.

Requirements:

Create a PHP page named file-uploads.php with a formusing 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 imagefile.

Process the form text information.

• Upon form submission, sanitize and validate the textinformation.
• If the information is valid, create a new lowercase username withthe first initial of the first name concatenated with the lastname. (IE: sherd)
• Set the first letter of the first and last names to uppercasethen concatenate the first name and last name into one field with aseparation 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 appropriateimage type and size is 100KB or less.
• If the image passes validation, check to see if it alreadyexists. If so, display an error and return the form to theuser..
• If the image file doesn't exist, upload the image to theserver.

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 validatethe form submission. Include sticky form fields and errormessages.

• Text fields must be present and convert any HTML tags presentusing 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 contentshould trigger the form to be redisplayed to the user with awarning to provide acceptable information.

Answer & Explanation Solved by verified expert
4.2 Ratings (541 Votes)
fileuploadsphp Please input your    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students