I am basically submitting form values to my controller and I am using CodeIgniter Framework. However, when I send the values to my controller's function, the page gets changed to the controller and leaves the index.php (current page)
index.php:
<form action="<?php echo base_url();?>index.php/LoginController/loginuser" method="post">
<input id="login_emailbox" name="login_emailbox" type="text" class="form-control welcome-login-email" placeholder="Email" required="">
<input id="login_passbox" name="login_passbox" type="password" class="form-control welcome-login-password" placeholder="Password" required="">
<button id="loginbtn" type="submit" class="btn btn-info" style="margin-left: 30px">Login</button>
</form>
LoginController.php:
class LoginController extends CI_Controller {
public function __construct()
{
parent::__construct();
}
function index()
{
$this->load->helper('html');
$this->load->helper('url');
$this->load->view('header');
$this->load->view('footer');
$this->load->view('index.php');
}
public function loginuser(){
echo $_POST['login_emailbox'];
echo $_POST['login_passbox'];
}
}
Steps I take during Runtime:
1) I browse to the index.php via => http://localhost/codeig/index.php/LoginController/index
2) Fill the form and hit submit. Values are submitted to the function: loginuser
3) Page gets redirected to the 'loginuser' function
How can I avoid this and basically send the values to the loginuser function in the controller without refreshing the current page?