how to submission PHP form using oop.

The action attribute of the form is for the script name you want to submit to. You want to submit your form to your hungry class to be processed, but this can not be done until you have instantiated your hungry class. You will need to use a script name as the action value in your form. Lets say you want to submit to temp.php, your form should look like this

<form action=”temp.php” method=”post” id=”searchMealForm”>
<input type=”search” size=”35″ placeholder=”What Food Are you looking for?” id=”mealName” class=”meal”/>
<input type=”search” placeholder=”City Area” id=”mealLocation” class=”meal”>
<input type=”submit” value=”Satisfy Me” id=”findMeal” />
</form>
then when this forms submits it will be sent to temp.php. To get your hungry class to process this form you need to make an instance of it in temp.php and with this instance, call searchMeal. temp.php should look something like this

<?php
require_once ‘hungryClass.php’;
$newSearch = new hungryClass();
$newSearch->searchMeal();
?>
or to put everything in one file

<?php
require_once ‘hungryClass.php’;

if($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
$newSearch = new hungryClass();
$newSearch->searchMeal();
exit();
}
?>
<form action=”<? echo $_SERVER[‘PHP_SELF’]?>” method=”post” id=”searchMealForm”>
<input type=”search” size=”35″ placeholder=”What Food Are you looking for?” id=”mealName” class=”meal”/>
<input type=”search” placeholder=”City Area” id=”mealLocation” class=”meal”>
<input type=”submit” value=”Satisfy Me” id=”findMeal” />
</form>