[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">
<?php
$path = '/application/index';
?>
<h1>Register</h1>
<?php echo form_open($path, $app_attr);?>
<label class="className" for="email">Email:</label>
<input class="className" type="text" name="email" id="email" value="" size="23" />
<label class="className" for="password">Password:</label>
<input class="className" type="password" name="password" id="password" size="23" />
<label class="className" for="conf_password">Confirm Password:</label>
<input class="className" type="password" name="conf_password" id="conf_password" size="23" />
<input type="submit" name="submit" value="APPLY" />
<input type="submit" name="submit" value="SAVE" />
</form>
</div>
<?php
switch($_POST['submit'])
{
case 'APPLY':
$path = "/application/apply";
echo 'apply';
break;
case 'SAVE':
$path = "/application/save";
echo 'save';
break;
}
?>
</body>