"POST" requestnot working on a real host |
I have a problem with post request. On my localhost every codes run well also POST request. As for on a real host POST requests not working. Dont understand why?
Here is my html codes <form action="<?php echo base_url()."/ayarlar/guncelle" ?>" method="post" enctype="multipart/form-data" > <div class="form-group"> <label>Web Sitesi İsmi</label> <input type="text" class="form-control" placeholder="Web Sitesi İsmi" name="siteismi" value=""/> </div> <div class="form-group mb-0"> <div> <button type="submit" class="btn btn-primary waves-effect waves-light mr-1"> Güncelle </button> </div> </div> </form> by the way at config.php public $baseURL = 'http://www.catidekorasyon.com/panel'; Controllers/ayarlar.php <?php namespace App\Controllers; class Ayarlar extends BaseController { public $viewFolder=""; public function __construct() { parent::__construct(); $this->viewFolder = "ayarlar_v"; $this->ayarlarModel = model('App\Models\AyarlarModel', false); $this->session=session(); } public function guncelle() { $viewData = new \stdClass(); $viewData->viewFolder = $this->viewFolder; helper(['form', 'url','tools','Text']); $validation = \Config\Services::validation(); $siteismi=$this->request->getPost("siteismi"); print_r($siteismi); die(); } and result is Array ( ) What are your opinions
ok i might not have the full answer but will start ..I'm not going to go into fine detail of your code nor look at construct, i will mention approach and method though .
First thing to note is your using Bootstrap; thats ok so am i.Your code is faint are you using Code: put your code here! you have <button> </button> you can do this: Code: <div class="form-group"> in terms of general approach . I Actually quote a "route" in my form and from the route, the system knows what class to use and which of class method to use . Lets look at route first: Code: $routes->post('newblog','Blog::newBlogArticle'); when a POST occurs to /newblog it uses class BLog and the class method which processes it will be newBlogArticle. How does the Blog class and method get the post data ? Code: <div class ="flex2"> I have a form, which only admin can access once logged in.The form has date submitted, title, and body of blog. On line 4 I tell the system that , when the form is submitted using "POST" it should go to route "newblog". IN routes the route tells the system which class and which method. I have a browse button ,to navigate from PC to select an image, because of that on line 4 i also stipulate "form_open_multipart". You can use helper('form') in controller, i have it in basecontroller , so i don't have to repeat myself. In summary there are , maybe alternative ways of doing it. I can't edit your post , if you can put in code blocks can see more easily please i have put in <?= csrf_field() ?> but maybe worry about that later, when it works live
You did not mention your routes. Did you include the guncelle URI to the POST route?
|
Welcome Guest, Not a member yet? Register Sign In |