Welcome Guest, Not a member yet? Register   Sign In
"POST" requestnot working on a real host
#1

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








                            
Reply
#2

(This post was last modified: 10-31-2020, 05:03 AM by captain-sensible.)

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">
<input type="submit" class ="btn-success" value="submit" />
  </div>
                          
// i'm lazy so i just use btn-success



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">
    <div class ="content">
    <div class="d-flex justify-content-center">
        <?= form_open_multipart('newblog'); ?>
    <?= csrf_field() ?>



      
       form fields etc, etc
<div class="form-group">
<input type="file" name="userfile" size="20" />
</div>
<div class="form-group">
<input type="submit" class ="btn-success" value="submit" />
</div>
      


<?php echo form_close();?>//end of form

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
Reply
#3

You did not mention your routes. Did you include the guncelle URI to the POST route?
Reply
#4

(This post was last modified: 10-31-2020, 12:51 PM by InsiteFX.)

he also has a beginning / forward slash on the form action which should be on his base_url.
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 11-01-2020, 02:54 AM by captain-sensible.)

try


<form action= "<?php echo base_url();?>/ayarlar/guncelle" method="post" enctype="multipart/form-data" >
Reply




Theme © iAndrew 2016 - Forum software by © MyBB