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.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>User Input Tracker</title>
</head>
<body>
<h1>Feedback Or Survey Form</h1>
<form method="post" action="thankyou.php">
    Name: <input type="text" name="name"><br>
    Email: <input type="email" name="email"><br>
    Age: <input type="number" name="age"><br>
    Feedback Message: <textarea type="text" name="feedback_message"></textarea><br>
    <button type="submit">Submit</button>
</form>
</body>
</html>

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.

<?php
// This below lines captures all the submitted data by the users
$submittedFields=array_keys($_REQUEST);
// The below lines display all the submitted field names
echo "<h1>Thanks for submitting!!!</h1>";
echo "<p>You have successfully submitted the below following fields:</p>";
echo "<ul>";
foreach ($submittedFields as $fields) {
    echo "<li>".htmlspecialchars($fields)."</li>";
}
echo "</ul>";
?>

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=>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>User Input Tracker</title>
</head>
<body>
<h1>Feedback Or Survey Form</h1>
<form method="post" action="thankyou.php">
    Name: <input type="text" name="name"><br>
    Email: <input type="email" name="email"><br>
    Age: <input type="number" name="age"><br>
    Feedback Message: <textarea type="text" name="feedback_message"></textarea><br>
    <button type="submit">Submit</button>
</form>
</body>
</html>

Output Page Of userinputtracker.html  Page=> 

Feedback Or Survey Form

Name: 
Email: 
Age: 
Feedback Message: 


Coding Page Of thankyou.php Page =>

<?php
// This below lines captures all the submitted data by the users
$submittedFields=array_keys($_REQUEST);
// The below lines display all the submitted field names
echo "<h1>Thanks for submitting!!!</h1>";
echo "<p>You have successfully submitted the below following fields:</p>";
echo "<ul>";
foreach ($submittedFields as $fields) {
    echo "<li>".htmlspecialchars($fields)."</li>";
}
echo "</ul>";
?>

Output Page Of thankyou.php Page =>

Thanks for submitting!!!

You have successfully submitted the below following fields:

  • name
  • email
  • age
  • feedback_message





  

Comments

Popular posts from this blog

Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String

PHP WEB DEVELOPMENT INTERVIEW QUESTIONS ASKED IN APOLLO HOSPITAL ALONG WITH MY OWN CONCEPTS AND MY OWN EXPLANATION ANSWERS(PART - 1) REST OF THE QUESTIONS AND ANSWERS WILL BE PREPARED BY ME IN MY NEXT BLOG

Mini Project On Multi User CRUD Operations(Create, Read, Update & Delete) Of Donar Details Of Indian Nationals Who Donate To Ramkrishna Math, Belur Math Using PDO (PHP Data Objects) With Proper Explanation Of Each And Every Individual Line Of The Code Of connection.php Page, form.php Page, formaction.php Page, admin_display.php Page, client_display.php Page, edit.php Page, editaction.php Page And delet.php Page (Here You Will Find The Image Of Sayang Sri Ramkrishna Dev, Sayang Sri Ma Sarada Devi & Sayang Sri Swami Vivekananda) In My CRUD Operation