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?
asked Mar 7, 2019 at 6:32
pbachman
1,0692 gold badges13 silver badges24 bronze badges
-
mention your local machine codeAshu– Ashu2019年03月07日 06:45:24 +00:00Commented Mar 7, 2019 at 6:45
-
Can you post your form code here?Himanshu Upadhyay– Himanshu Upadhyay2019年03月07日 07:56:28 +00:00Commented Mar 7, 2019 at 7:56
-
show us your controller codeAbdulla Nilam– Abdulla Nilam2019年03月07日 12:42:23 +00:00Commented Mar 7, 2019 at 12:42
1 Answer 1
i think you should use this method :
$pos = $this->input->post();
if(isset($pos['XYZ']))$xyz = $pos['XYZ'];else $xyz='';
Sign up to request clarification or add additional context in comments.
3 Comments
pbachman
The $pos array and $pos['XYZ'] is always empty.
Steve Good Job
what me thod are you using for post method ?
Steve Good Job
i think the problems is in here
<form method="post" id="login_form" action="/index.php/login"> try change to <form method="post" id="login_form" action="/login">lang-php