Task 7 - Form Handling and Generating Dynamic Views


First you must review forms code samples we discussed in class to understand how to create forms with all input controls, receive submitted data at server side and how to generate update form. After getting basic understanding of forms, do below givens tasks. Without doing below tasks, do not expect to solve forms related question in quiz and sessional 2 exam.


Task 7.1 
Assume a form is submitted to handler.php script, write handler.php script such that it should display all parameter names and values in tabular format ie. two columns, key name in first column and value in second column. Show the method name used to submit the data. The handler should work, whether the form is submitted using GET or POST.


Task 7.2
Do this task using postback approach. Make a form with option to attach up to 5 pictures. Write fileshandler.php script that shall save all submitted files in filestore directory (located in same folder where handler script is saved). Rename each file to <original name>-<random string>.<extension> when saving at server.

Make another script showpics.php, it should display all pics stored in filestore folder. Show delete link with each picture, when user click that link, delete that picture from the filestore directory. Google the PHP functions used to traverse directory and remove files. (Do not copy paste the code to save files at server but use loop to iterate $_FILES array and process each file in loop body). When the form is submitted, show each file name and file size (in KB). Also show total size of all files (in MB).


Task 7.3
Make show-update-form.php file that should display an update form. Request should contain user id in "id" parameter (you can pass from address bar directly). Use below defined array to populate form input fields. I hope you can guess the input types and number of fields from below data. If request do not contain id parameter, show error "id is required to show update form". Use Bootstrap for forms and other elements styling.

$user = array(
    "BCS-SP14-50" => array("name" => "Arham", "age" => 20, "city" => "Lahore", "gender" => "male", "subjects" => array("OOP", "Web Technologies", "Big Data", "Machine Learning")),
    "BCS-SP14-70" => array("name" => "Suzu", "age" => 25, "city" => "Islamabad", "gender" => "female", "subjects" => array("Web Technologies", "Fine Arts")),
    "BCS-SP14-90" => array("name" => "Arslan", "age" => 30, "city" => "Karachi", "gender" => "male", "subjects" => array("Web Technologies", "Big Data", "Web Design")));


Comments

Post a Comment