dongtingxiao4697 2019-03-07 06:32
浏览 38
已采纳

CodeIgniter 3.x POST为空

I'm using the latest CodeIgniter3.1 Version in my project. When I submit the form or use an AJAX call, I always get an empty $this->input->post('XYZ'). It works on my local machine, but not on the server.

The csrf_protection is set to FALSE and a .htaccess file does exist

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
 ErrorDocument 404 /index.php
</IfModule>

Here is my Form Code, it doesn't matter if i use "form_open" or use it directly like this, it only works on my local dev machine:

<form method="post" id="login_form" action="/index.php/login">
        <label for="email"><?php echo $this->lang->line('username'); ?> *</label>
        <input type="text" name="email" id="email" class="logfeld" autocomplete="username" />
        <label for="passwort"><?php echo $this->lang->line('password'); ?> *</label>
        <input type="password" name="passwort" id="passwort" class="logfeld" autocomplete="current-password" />
        <input class="sendbut" type="submit" name="login" value="<?php echo set_value('passwort'); ?>" />
    </form>

How can I fix that problem?

  • 写回答

1条回答 默认 最新

  • doujiao9574 2019-03-07 08:39
    关注

    i think you should use this method :

    $pos = $this->input->post();
        if(isset($pos['XYZ']))$xyz = $pos['XYZ'];else $xyz='';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?