Reputation: 23
In my index.php I am trying to login and I have to get input values. Then I am sending to Memberlogin.php controller using session.
In index.php first lines
<?php
ob_start();
ini_set('session.cookie_domain','.mydomain.com');
defined('BASEPATH') OR exit('No direct script access allowed');
?>
I am trying to get values like this
<h2 style="text-align: center">Login Area</h2>
<table>
<form action="<?php echo site_url()."/Memberlogin/login";?>"method="post">
<tr>
<td>UserName</td>
<td><input type="text" name="user_name" maxlength="20" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" maxlength="20" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="login" value="LOGIN!" /></td>
</tr>
</form>
</table>
There is no syntax error.
Here is my Memberlogin.php controller
<?php
ob_start();
ini_set('session.cookie_domain','.mydomain.com');
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Memberlogin extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('session');
and here is my login function in Memberlogin.php
function login()
{
$user_name = $this->input->post('user_name', TRUE);
$password = $this->input->post('password', TRUE);
if((!empty($user_name)) and (!empty($password)))
{ ...
}
But it is directly going to else which redirects to index.php
Upvotes: 0
Views: 72
Reputation: 490
the action for your form is incorrect, replace it with this
action="<?php echo site_url('Memberlogin/login');?>"
also add the following in the form tag
enctype="multipart/form-data"
<form action="<?php echo site_url('Memberlogin/login');?>" method="post" enctype="multipart/form-data">
or use the url helper by doing this
Upvotes: 0