Welcome Guest, Not a member yet? Register   Sign In
form fields are being cleared when refrshing the web page
#11

[eluser]nir[/eluser]
i am getting the exact opposite result.
you would expect it stay there until you successfully submitted your data.
thanks,
nir
#12

[eluser]TheFuzzy0ne[/eluser]
You've only specified two of the fields to the form validation library. You need to add them all, even if they don't require validation.
#13

[eluser]nir[/eluser]
i'ts all there, i just removed it from the post because i've reached the limit of 6,000 characters.

thanks,
nir
#14

[eluser]TheFuzzy0ne[/eluser]
OK, please repost your validation rules, and your view.
#15

[eluser]nir[/eluser]
================ Controller ===========================
Code:
<?php
class Registration extends Controller {

    function Registration()    {
        parent::Controller();
        session_start();    
        
        
    }
    
    
    function index()
    {
        if(empty($_POST))
        {
            $this->load->model('MCaptcha');
            $captcha = $this->MCaptcha->generateCaptcha();
            $_SESSION['captchaWord'] = $captcha['word'];
            $data['captcha'] = $captcha;
            $data['title'] = 'FORM';
            $this->load->vars($data);
            $this->load->view('registration.php',$data);
        }
        else
        {
            //testing
        }
    }
    
    function register() //adding new user in the Database
    {
        //===========VALIDATION RULES===============
        $rules['username']= "trim|required|xss_clean";
         $rules['email']= "trim|required|xss_clean|valid_email";
         $rules['password'] = "trim|required|matches[passconf]|xss_clean";
        $rules['passconf'] = "trim|required|xss_clean";
         $rules['captcha_input'] = "trim|required|xss_clean";
         $this->validation->set_rules($rules);
        
         $fields['username'] = 'Username';
         $fields['email'] = 'Email';
         $fields['password'] = 'Password';
        $fields['passconf'] = 'Password Confirmation';
         $fields['captcha_input'] = 'Code';
         $this->validation->set_fields($fields);
        
        if ($this->validation->run() == TRUE)
        {
             if(strcasecmp($_SESSION['captchaWord'],$_POST['captcha_input']) == 0)
             {
                 $username = $this->input->post('username');
                if(!$this->MUsers->getUserAccount($username))
                {
                    if ($this->input->post('username')){
                        $this->MUsers->addUser();
                        $this->session->set_flashdata('message','User Created Successfully !');
                        redirect('application','refresh');
                    }
                    else
                    {
                        //testing
                    }
                    
                }
                else
                {
                    $this->session->set_flashdata('error','User Already Exist !');
                    $data['title'] = "Form";
                    $this->load->vars($data);
                    //$this->load->view('registration',$data);
                    redirect('registration');
                }
             }    
            else
            {
                $this->session->set_flashdata('error','Characters Do Not Match !');
                redirect('registration');
            }
            
        }
        else
        {
            $data['title'] = "Error";
            $this->load->vars($data);
            $this->load->view('registration_form_error',$data);
        }
        
    }

}  
?>

=============================== View ==================================
Code:
<?php  $this->load->view('header');  ?>

<div id="content">
    &lt;?php
    if ($this->session->flashdata('error')){
        echo "<div class='message'>";
        echo $this->session->flashdata('error');
        echo "</div>";
    }
    ?&gt;
    <div id="form">
        <h3>Registration Form</h3>
        
        
            &lt;!--  //$pcdata = array('name'=>'passwordConfirm','id'=>'pc','size'=>35 );--&gt;
            &lt;?php $captchaData = array('name'=>'captcha_input','id'=>'captcha_input','size'=>35 );
            
            echo form_open("registration/register"); ?&gt;
            
            <p><label for='uname'><span class='starLabel'>* </span>Username : <br/>
            <span class='smallLabel'>Usernames must be at least 4 characters long</span></label>
            &lt;?php $data = array('name'=>'username','id'=>'username','size'=>35,'value' => set_value('username'));
            echo form_input($data); ?&gt;
            </p>
            
            <p><label for='email'><span class='starLabel'>* </span>Email Address: </label>
            &lt;?php $data = array('name'=>'email','id'=>'email','size'=>35);
            echo form_input($data);?&gt;
            </p>
            
            
            <p><label for='p'><span class='starLabel'>* </span>Password : <br/>
            <span class='smallLabel'>Passwords must be at least 5 characters long</span></label>
            &lt;?php $data = array('name'=>'password','id'=>'password','size'=>35 );
            echo form_password($data);?&gt;
            </p>
            
            <p><label for='pc'><span class='starLabel'>* </span>Password Confirm : </label>
            &lt;?php $data = array('name'=>'passconf','id'=>'passconf','size'=>35 );
            echo form_password($data);?&gt;
            </p>
            
            <p style='height:50px;'>&lt;?php echo $captcha['image']?&gt;</p>
            
            <p><label for='Captcha'><span class='starLabel'>* </span>Type in the code: <br/>
            <span class='smallLabel'>Type in the characters as it shows in the image above</span></label>
            &lt;?php echo form_input($captchaData); ?&gt;
            </p>
            
            
            <div id='form-submitButton'>
            <p style='border-bottom:none;'>&lt;?php echo form_submit('submit','Submit');?&gt;</p>
            </div>
            &lt;?php echo form_close();?&gt;
        
    </div>
</div>    

&lt;?php  $this->load->view('footer');  ?&gt;

thank you,
nir
#16

[eluser]TheFuzzy0ne[/eluser]
I only see set_value() being used on one input. You still need to use it with your other form fields.
#17

[eluser]nir[/eluser]
I've changed it.
Still, i'm getting the same strange behavior




Theme © iAndrew 2016 - Forum software by © MyBB