Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 Post Problem
#1

I started use codeigniter 4 so new. Everything work properly on localhost but after insatalling on a host only "post" request not working. I cant get any valu after post request.
Html



Code:
<form  action="<?php echo base_url()."/slider/ekle" ?>" method="POST" enctype="multipart/form-data" >

        <div class="form-group">
          <label>Başlık</label>
          <input type="text" class="form-control"  placeholder="Slider başlığı" name="baslik" value=""/>
 
       </div>

      <div class="form-group mb-0">
         <div>
            <button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Ekle</button>
         </div>
      </div>
</form>
Ekle.php (Controller )
Code:
public function ekle()
    {

        $baslik=$this->request->getPost("baslik");
        $aciklama=$this->request->getPost("aciklama");

        print_r($baslik);
        die();
}
What i mean is everycodes are well working on "localhost" but "post" request not working on my host
After 

Code:
print_r($baslik); die();
 returning page is loading empty.


What could be the problem's sourche?
Reply
#2

(This post was last modified: 10-15-2020, 11:19 PM by InsiteFX.)

Did you place the ending slash / on your app/Config/App.php base_url ?

PHP Code:
<form  action="<?php echo base_url('Controller/Method'); ?>" method="POST" enctype="multipart/form-data" >

// So if your controller is Ekle and your method is ekle it would be like this/
<form  action="<?php echo base_url('ekle/ekle'); ?>" method="POST" enctype="multipart/form-data" 

Not sure why you would have the controller and method using the same name?

You may also need to use all lowercase for the file names, depending on the server.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(10-15-2020, 11:15 PM)InsiteFX Wrote: Did you place the ending slash / on your app/Config/App.php base_url ?

PHP Code:
<form  action="<?php echo base_url('Controller/Method'); ?>" method="POST" enctype="multipart/form-data" >

// So if your controller is Ekle and your method is ekle it would be like this/
<form  action="<?php echo base_url('ekle/ekle'); ?>" method="POST" enctype="multipart/form-data" 

Not sure why you would have the controller and method using the same name?

You may also need to use all lowercase for the file names, depending on the server.

My condtroller is slider and method is ekle!!! and basrUrl is http://www.catidekorasyon.com/panel
Reply
#4

(This post was last modified: 10-16-2020, 04:48 AM by includebeer.)

(10-15-2020, 11:15 PM)InsiteFX Wrote: You may also need to use all lowercase for the file names, depending on the server.

No. The file and the class name must start with a capital letter. 

See the doc: https://codeigniter4.github.io/userguide...ello-world

Quote:The file must be called ‘Helloworld.php’, with a capital ‘H’.
Controller class names MUST start with an uppercase letter and ONLY the first character can be uppercase.

(10-15-2020, 11:15 PM)InsiteFX Wrote:
PHP Code:
<form  action="<?php echo base_url('Controller/Method'); ?>" method="POST" enctype="multipart/form-data" >

// So if your controller is Ekle and your method is ekle it would be like this/
<form  action="<?php echo base_url('ekle/ekle'); ?>" method="POST" enctype="multipart/form-data" 

This depend on how the routes are defined. If auto routing is turned off this won't work either. 
PHP Code:
$routes->setAutoRoute(false); 

https://codeigniter4.github.io/userguide...uting.html
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

Then your form open would be like this.

PHP Code:
// So if your controller is Slider and your method is ekle it would be like this/
<form  action="<?php echo base_url('slider/ekle'); ?>" method="POST" enctype="multipart/form-data" 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(10-16-2020, 01:07 PM)InsiteFX Wrote: Then your form open would be like this.

PHP Code:
// So if your controller is Slider and your method is ekle it would be like this/
<form  action="<?php echo base_url('slider/ekle'); ?>" method="POST" enctype="multipart/form-data" 

There’s no way to know for sure until we see how the routes are configured.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#7

In your last lines in the controller, replace these lines

print_r($baslik);
die();

with

echo print_r($baslik, true);
Reply




Theme © iAndrew 2016 - Forum software by © MyBB