Help to understand the use of OOP in PHP

Divided from other topic because it was not related to the subject of discussion

Continuing the discussion from How would you use OOP to handle a form?:

The form action has to to be a valid URL (or left blank). If you want to use the results of the form as input to the hungryClass::searchMeal() method then you first have to submit the form and retrieve those values from the $_POST array.

Something along these lines (rough example):


    require_once 'hungryClass.php';

    $mealName    = filter_input(INPUT_POST, 'mealName', FILTER_SANITIZE_STRING);
    $mealLocation = filter_input(INPUT_POST, 'mealLocation', FILTER_SANITIZE_STRING);

    $newSearch = new hungryClass();
     // Just guessing at how your class works here
    $results = $newSearch->searchMeal($mealName, $mealLocation);

    // Do something with search results

<form action="" method="post" id="searchMealForm">

  <input type="search" size="35" placeholder="What Food Are you looking for?" name="mealName" class="meal">
  <input type="search" placeholder="City Area" name="mealLocation" class="meal">
  <input type="submit" value="Satisfy Me" id="findMeal">


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.