MINI PROJECT ON USER INPUT TRACKER (STORE FORM SUBMISSIONS (LIKE FEEDBACK OR SURVEY DATA) IN AN ASSOCIATIVE ARRAY AND DISPLAY ONLY THE FIELDS (KEYS) THAT WERE FILLED OUT BY THE USER) AND TO GET ALL SUBMITTED FIELD NAMES FROM THE USER INPUT BY USING ARRAY_KEYS() FUNCTION
MINI PROJECT ON USER INPUT TRACKER BY USING ARRAY_KEYS() FUNCTION (STORE FORM SUBMISSIONS (LIKE FEEDBACK OR SURVEY DATA) IN AN ASSOCIATIVE ARRAY AND DISPLAY ONLY THE FIELDS (KEYS) THAT WERE FILLED OUT BY THE USER) AND TO GET ALL SUBMITTED FIELD NAMES FROM THE USER INPUT BY USING ARRAY_KEYS() FUNCTION
STEP 1: In my first step first I have created an HTML form where I have design a simple html form which html file I have named it as userinputtracker.html file with multiple input fields like Name, Email, Age And Feedback Message with button submit along with method post as because the post method is the most secure method so that it can send the data securely and with action as thankyou page i.e. thatnkyou.php. I have provided name attributes in each input fields so that it can be accessed in PHP.
STEP 2: In my thatnkyou.php page I have used the $_REQUEST method to collect all the submitted form data, if you want you can use $_POST method also if you want because $_POST method is the most secure method. And here I have used array_keys($_POST) function to return the arrays with only keys and not with values and to list which fields were submitted.
Here I have also used foreach statement so that it can perform(iterate) over elements of an array or an object. Which syntax is "$variable as $key => $value" as listed below.
foreach ($variable as $key => $value) {
// code...
}
Then I have used htmlspecialchars to convert their special characters to their corresponding HTML entities where within htmlspecialchars I have used $fields.
STEP 3: So, in my output page of I need to fill out my html form input fields Name, Email, Age And Feedback Message of userinputtracker.html and then I need to click on submit then I will be able to see my output on thankyou.php page as shown below.
Coding Page Of userinputtracker.html Page=>
Output Page Of userinputtracker.html Page=>
Feedback Or Survey Form
Coding Page Of thankyou.php Page =>
Output Page Of thankyou.php Page =>
Thanks for submitting!!!
You have successfully submitted the below following fields:
- name
- age
- feedback_message
Comments
Post a Comment