Welcome Guest, Not a member yet? Register   Sign In
problem with form data
#18

(04-12-2023, 01:09 AM)anuragk Wrote:
(04-12-2023, 01:01 AM)kenjis Wrote: When you post the HTML form?

Can you show all code for the controller and the view?

View Page
Code:
<?= validation_list_errors() ?>
  <form action="<?=base_url();?>appointment/" method="post" name="rulesForm">
  <div class="form-group mt-3">
  <input type="text" name="name" />
  <input style="height: 14px;" type="checkbox" name="rulescheck" id="rulescheck" required/>
  <label for="rulecheck" class="rule">Agree |</label>
  </div>
  <div class="text-center"><button type="submit" name="rulesSubmit" id="rulesSubmit">Submit</button></div>
  </form>


Controller Page

PHP Code:
<?php

namespace App\Controllers;
use 
App\Models\Appointments;

class 
Appointment extends BaseController
{
    public function index()
    {
        return view('pages/kp');
    }
 
 public function 
rules()
 {
 
helper('form');
 
$head['title'] = "Rules & Regulations";
 
$head['breadcrumb'] = "Rules";
 
 return 
view('template/header'$head)
 .
view('pages/rules')
 .
view('template/footer');
 }
 
 public function 
appointmentForm()
 {
 
helper('form');
 
$data $this->request->getPost();
 
 
print_r($data);
 }


Route Page

PHP Code:
<?php

namespace Config;
use 
App\Controllers\Appointment;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

/*
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
// $routes->setAutoRoute(false);

/*
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index');

//coutom routes
$routes->get('contactus''Home::contact');
//$routes->get('rules', 'Appointment::rules');
$routes->match(['get''post'], 'rules', [Appointment::class, 'rules']);
//$routes->post('appointment', 'Appointment::appointmentForm');
$routes->match(['get''post'], 'appointment', [Appointment::class, 'appointmentForm']);
$routes->get('drkpkushwaha''Appointment::index');
//$routes->view('this', 'pages/welcome_message');  //directly call view without controller

/*
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (is_file(APPPATH 'Config/' ENVIRONMENT '/Routes.php')) {
    require APPPATH 'Config/' ENVIRONMENT '/Routes.php';


I have had issues where there is a trailing '/' on the form action, suggest you try
Code:
<form action="<?= base_url('appointment'); ?>" method="post" name="rulesForm">
Dirk B.
Abatrans Software
No SEO spam - see forum guidelines
Reply


Messages In This Thread
problem with form data - by anuragk - 04-11-2023, 07:50 AM
RE: problem with form data - by gosocial2 - 04-11-2023, 12:59 PM
RE: problem with form data - by anuragk - 04-11-2023, 11:21 PM
RE: problem with form data - by kenjis - 04-11-2023, 11:51 PM
RE: problem with form data - by anuragk - 04-11-2023, 11:59 PM
RE: problem with form data - by kenjis - 04-12-2023, 12:09 AM
RE: problem with form data - by anuragk - 04-12-2023, 12:36 AM
RE: problem with form data - by kenjis - 04-12-2023, 12:46 AM
RE: problem with form data - by anuragk - 04-12-2023, 12:55 AM
RE: problem with form data - by kenjis - 04-12-2023, 01:01 AM
RE: problem with form data - by anuragk - 04-12-2023, 01:09 AM
RE: problem with form data - by abatrans - 04-13-2023, 12:13 AM
RE: problem with form data - by anuragk - 04-13-2023, 05:12 AM
RE: problem with form data - by kenjis - 04-12-2023, 01:29 AM
RE: problem with form data - by anuragk - 04-12-2023, 02:06 AM
RE: problem with form data - by kenjis - 04-12-2023, 05:35 AM
RE: problem with form data - by anuragk - 04-12-2023, 06:28 AM
RE: problem with form data - by HermyC - 04-12-2023, 12:57 PM
RE: problem with form data - by anuragk - 04-12-2023, 10:55 PM
RE: problem with form data - by InsiteFX - 04-14-2023, 10:42 PM
RE: problem with form data - by kenjis - 04-14-2023, 11:19 PM
RE: problem with form data - by anuragk - 04-18-2023, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB