Codeigniter, how can I call the controller / method inside the onclick button

I want to call the controller with the onclick method. I solved it, but I want to find a solution for this.

<button type="button" class="btn btn-success" onclick="<?php  ?>">Sign Up</button>
+4
source share
6 answers

you can use this

<button type="button" class="btn btn-success" 
        onclick="<?php echo base_url()?>controller/function">Sign Up</button>
+7
source

Try this code:

<button type="button" class="btn btn-success" onclick="window.location='<?php echo site_url("controller/fun_name");?>'">Sign Up</button>
+14
source
 <?php echo base_url(); ?> "controller/function"

+2

.

home "

: "

<form action="home/insert" method="POST">
//add codes here
</form>

http://www.w3schools.com/tags/att_form_action.asp

+1

, . .

<?=   anchor("controllerclassname/method",'Sign Up',['class'=>'btn btn-success float-left']); ?>
0

, ;)

<a href="<?php echo base_url().'controller/function'; ?>"><button class="form-control">Signup</button></a> 
0

Source: https://habr.com/ru/post/1524407/


All Articles