Question

i have designed this form for login modal:

<tr>
        <td></td>
        <td><?php echo form_submit('submit', ' Log In', 'class="btn btn-primary btn-lg btn-block"'); ?>
            <?php echo form_submit('forget', ' Forget Password ', 'class="btn btn-warning btn-lg btn-block"'); ?>
        </td>
 </tr>

both of these buttons are doing same works how can I isolate which one has pressed?

thanks for everyon

Was it helpful?

Solution 2

if (!empty($_POST['submit'])) {
  // submit button pressed
}

if (!empty($_POST['forget'])) {
  // forgot password button pressed
}

OTHER TIPS

You can obtain this by using this HTML:

<tr>
    <td></td>
    <td>
        <button type="submit" name="action" value="submit" class="btn btn-primary btn-lg btn-block"> Log In </button>
        <button type="submit" name="action" value="forget" class="btn btn-warning btn-lg btn-block"> Forget Password </button>
    </td>
</tr>

Then use the POST data like this:

$action = $this->input->post('action');
if($action == 'submit') {
    // execute code to log in
}
if($action == 'forget') {
    // execute code to forget the password
}

Have you tried this:

if($this->input->post('submit'))
{
   // what to do in case of submit    
}

if($this->input->post('forget'))
{
   // what to do in case of forget
}

In the view use a multipart form instead of a normal form.Like this

<?php echo form_open_multipart('Controller/function')?>

Then simply use your submit buttons

Then again in the controller use post with submit fields names

if($_POST['SUBMIT1'])
{
 //code
}

if($_POST['SUBMIT2'])
{
 //code
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top