Welcome Guest, Not a member yet? Register   Sign In
multiple submit buttons that execute different processing scripts
#1

[eluser]hidden_within[/eluser]
I have an application form designed for students to apply at a school. Since the form is rather long I would like to give the user the option to save the form or submit it once it has been completed. I have 2 submit buttons and I want to call one function called "save" from the controller and a function called "apply" based on what the user chooses. What I have right now might not be the route I should take. Neither method gets called and the testing method that I have that does get called which is the index function does not output anything either. Any suggestions would be awesome. Thanks in advance.

Here's my controller
Code:
<?php
    class Application extends Controller {
        
        function Application()
        {
            parent::Controller();
            $this->load->model->('application_model');
        }//end application
        
        function index()
        {
            $this->load->view('dts_application');
        }
        function validate()
        {
            //validate the form values
            //validation will be based on whether the user is saving the form or applying
            //must at least have an email address in order to save the form otherwise store nothing
            
        }//end validate
        
        function apply()
        {
            //send the application in for review
            $this->load->view('apply');
        }//end apply
        
        function save()
        {
            //store data to the database
            $this->load->view('save');
        }//end save
    }//end class
?>

Here's my view
Code:
<body>
<?php
  //form attributes    
  //may need to change the class for styling if the class isn't needed then the attribute can be removed
  $app_attr = array('class' => 'some_class','id' => 'dts_form');    
?>
<body>
  <div id="dts_app">
      &lt;?php
        $path = '/application/index';  
    ?&gt;
    <h1>Register</h1>
    &lt;?php echo form_open($path, $app_attr);?&gt;
    <label class="className" for="email">Email:</label>
    &lt;input class="className" type="text" name="email" id="email" value="" size="23" /&gt;
    <label class="className" for="password">Password:</label>
    &lt;input class="className" type="password" name="password" id="password" size="23" /&gt;
    <label class="className" for="conf_password">Confirm Password:</label>
    &lt;input class="className" type="password" name="conf_password" id="conf_password" size="23" /&gt;
    &lt;input type="submit" name="submit" value="APPLY" /&gt;
    &lt;input type="submit" name="submit" value="SAVE" /&gt;
    &lt;/form&gt;
  </div>
  &lt;?php
    switch($_POST['submit'])
    {
        case 'APPLY':
            $path = "/application/apply";
            echo 'apply';
            break;
        
        case 'SAVE':
            $path = "/application/save";
            echo 'save';
            break;
    }
   ?&gt;
&lt;/body&gt;


Messages In This Thread
multiple submit buttons that execute different processing scripts - by El Forum - 01-05-2011, 09:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB