RahulAN
RahulAN

Reputation: 117

How to link page with button click in Codeigniter?

I am trying to load a page on click, I created an email verification link which open the page and updates my Database all it works fine, but the page contains a button which i want to be clicked by user and open first page which have login window. My verify.html:

    <div class="container container-table">
    <div class="row vertical-center-row">
        <div class="text-center col-md-4 col-md-offset-4" style="background:blue">
            <h3> Thankyou For Veryfing</h3>    
            <p>You Are Verified</p>
            <form action="login.php/verify_to_login" method="post">
                <button type="submit" class="btn btn-success" >Sign Up>Go To Login</button> 
            </form>        
        </div>
    </div>
</div>  

My Controller function which loads the verify page like this : http://localhost/index.php/login/verify/1567af19e10ce4

        public function verify($VerificationCode){
         $this->load->model('My_model');
         $this->load->helper('url');
         $this->My_model->verifymail($VerificationCode);
         /* Send to the verification page */
         $this->load->view("verify.html");
    }

This is my verify_to_login() function which i want when i click on button it should open header.html, This should work like http://localhost/index.php/login/verify_to_login but instead this it is showing http://localhost/index.php/login/verify/login.php/verify_to_login when i click on the button public function verify_to_login(){ $this->load->view("header.html"); }

I am unable to understand why is this happening.?? :(

Upvotes: 0

Views: 24371

Answers (2)

Masnad Nihit
Masnad Nihit

Reputation: 1996

On html

<form method="" action="<?php  echo base_url(); ?>​controller_name/function_name">
       <button id="submit-buttons" type="submit" ​​​​​>Submit 1</button>
</form>

And on Controller

function functionname(){
    $this->load->view('some_view')
}

So basically your controller is fine, so just fix the button by putting the controller name and then the function name and all should work hopefully.

Upvotes: 1

Alaa M. Jaddou
Alaa M. Jaddou

Reputation: 1189

try

this

<button type="submit" class="btn btn-success" onclick="window.location.replace('YOUR_LINK_HERE');">Sign Up>Go To Login</button>

OR

<button type="submit" class="btn btn-success" onclick="window.location.href('YOUR_LINK_HERE');">Sign Up>Go To Login</button>

Upvotes: 1

Related Questions