admin管理员组文章数量:1200964
i have a form submission in my view page as follow:
<form class="propertyForm" method="POST" action="<?= url_to('props.estimate.price'); ?>">
<label for="roomCount" style="display: block; margin: 5px 0;">Room Count:</label>
<input type="number" name="roomCount" id="roomCount" required style="width: 100%; padding: 10px; margin-bottom: 5px;">
<label for="size" style="display: block; margin: 5px 0;">Size (sq ft):</label>
<input type="number" name="size" id="size" required style="width: 100%; padding: 10px; margin-bottom: 5px;">
<label for="floor" style="display: block; margin: 5px 0;">Floor:</label>
<input type="number" name="floor" id="floor" required style="width: 100%; padding: 10px; margin-bottom: 5px;">
<label for="districtClass" style="display: block; margin: 5px 0;">District Class:</label>
<input type="text" name="districtClass" id="districtClass" required style="width: 100%; padding: 10px; margin-bottom: 5px;">
<label for="buildingAge" style="display: block; margin: 5px 0;">Building Age Category:</label>
<input type="number" name="buildingAge" id="buildingAge" required style="width: 100%; padding: 10px; margin-bottom: 5px;">
<input type="submit" value="Calculate" style="width: 100%; padding: 10px;">
</form>
and here is my controller method:
public function estimatePropPrice() {
// Log all POST data
$postData = $this->request->getPost();
log_message('info', 'Received POST data: ' . print_r($postData, true));
// Get values from input
$roomCount = $this->request->getPost('roomCount');
$size = $this->request->getPost('size');
$floor = $this->request->getPost('floor');
$districtClass = $this->request->getPost('districtClass');
$buildingAge = $this->request->getPost('buildingAge');
// Create a new point from the input data
$testPoint = [
'RoomCount' => $roomCount, // Changed to match the database column name
'Size' => $size,
'Floor' => $floor,
'District_Class' => $districtClass,
'BuildingAge' => $buildingAge, // Changed to match the database column name
];
.....
but in controller i cant get the posted data; while i add the requirements as follow to routs:
$routes->get('prop-estimate', 'Properties\PropertiesController::estimatePropPrice',['as'=>'estimate.prop.price']);
$routes->post('estimatePropPrice', 'Properties\PropertiesController::estimatePropPrice',['as'=>'props.estimate.price']);
but i think i miss something;
(i use local host and zampp)
can anyone help to disolve? thanks in advance.
solve my code misunderstood and make my code work
本文标签: phpretrive form data in controller method in codeigniter 4 and routs requirementsStack Overflow
版权声明:本文标题:php - retrive form data in controller method in codeigniter 4 and routs requirements - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738576102a2100888.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论