Code:
function email()
{
$old_email_error = false;
$this->load->library('auth');
$this->auth->checkNotLoggedIn();
$this->_setup_email_validation();
if ($this->validation->run())
{
if (@$_POST['email'])
{
$userId = $this->auth->getUser()->userId;
$old_email = @$_POST['old_email'];
$query = $this->db->get_where('user', array('email' => $old_emai));
if($query)
{
$data = array(
'email'=>$milo,
);
$this->db->update('user', $data, array('id' => $userId));
}
else
{
$old_email_error = "Wrong Old e-mail";
}
}
}
$this->load->library('design');
$this->design->header('account');
$data['javascript'] = $this->validation->javascript();
$this->load->view('change_mail',$data);
$this->design->footer();
}
Code:
<h1>
<a href="/settings">Account settings </a> :: Change e-mail
</h1>
<?php echo $javascript; ?>
<?php echo form_errors(); ?>
<?php
$old_milo = @htmlspecialchars($_POST['old_email']);
$milo = @htmlspecialchars($_POST['email']);
$milo2 = @htmlspecialchars($_POST['email2']);
?>
<!--form begin-->
<form action="/settings/email" method="post" class="base sys">
<fieldset class="group">
<label for="email" <?php echo field_error('old_email'); if($old_email_error) echo $old_email_error;?>>
<span>Old e-mail address</span>
<input id="old_email" name="old_email" type="text" value="" />
</label>
<label for="email"<?php echo field_error('email');?>>
<span>New e-mail address</span>
<input id="email" name="email" type="text" value="<?php echo $milo; ?>" />
</label>
<label for="email2"<?php echo field_error('email2');?>>
<span>Re-type new e-mail address</span>
<input id="email2" name="email2" type="text" value="<?php echo $milo2; ?>" />
</label>
</fieldset>
<fieldset>
<input type="submit" name="email" value="Change e-mail" class="b3s register"/>
</fieldset>
</form>
<!--end form-->