Welcome Guest, Not a member yet? Register   Sign In
form validation help PLEASE
#21

[eluser]flaky[/eluser]
basically this
Code:
$salt = "some random characters, best when having a lot of them";
md5($salt . $password);
#22

[eluser]JHackamack[/eluser]
In summary:
Salts add on or randomize your password more than just md5. Because of the weakness of md5 people have "rainbow tables" which list every combination of word and some numbers easily md5. If they got a hold your database they would compare your file with the rainbow table. If you salt it, and keep the salt a secret, you have secured your data better than the average bear.
#23

[eluser]dadamssg[/eluser]
hmm good to know thanks. Now i wonder why im not getting error messages for my rules...dangit. Im getting my custom flashdata message but not the other others. Like if i just submit a blank form i SHOULD get an error message saying that the fields are required.

login_view
Code:
<?php echo validation_errors(); ?>

<?php if($this->session->flashdata('message')) : ?>
    <p>&lt;?=$this->session->flashdata('message')?&gt;</p>
    
&lt;?php endif;
echo form_open('login');
?&gt;
<p>&lt;input type='text' name='username' /&gt;&lt;/p>
<p>&lt;input type='password' name='password' /&gt;&lt;/p>
<p>&lt;?=form_submit('login', 'Login')?&gt;</p>
&lt;/form&gt;
#24

[eluser]flaky[/eluser]
because of this
Code:
redirect('mains');
do not redirect when validation fails just call the function that renders the login again
#25

[eluser]JHackamack[/eluser]
if you want to see the "required" text, etc above each form value follow the example:
by using form_error and the name of the value
&lt;?php echo form_error('username'); ?&gt;
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;

<h5>Password</h5>
&lt;?php echo form_error('password'); ?&gt;
&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50" /&gt;
#26

[eluser]dadamssg[/eluser]
Flaky, im using multiple controllers. I wanted to seperate my login controller from my mains controller. The mains controller loads that view...the login_view is only a small piece of the overall page. my mains controllers index beginning looks like this

Code:
function index()
    {
        $data['title'] = "Home";
        $data['heading'] = "All Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_all_events();
        
        $this->load->view('header_view', $data);

        $this->load->view('login_view', $data);
        
        $this->load->view('main_view', $data);
    }

and my login_view form submits to the login controller
#27

[eluser]dadamssg[/eluser]
i know that using the mvc framework is designed to seperate things and keep them in order. I will be using multiple forms so i thought i would just use a controller to hold all of those form functions
#28

[eluser]JHackamack[/eluser]
it is a good idea in theory to have all the login functions on one controller, and all the other functions their respective controllers, sometimes it doesn't work like that. What I would recommend is moving the index code of the "mains" and place that content in addition to the content you have in the login page. That would allow you to load the views in the login, and provide people a nice url to have bookmarked for login (sitename.com/login) Again, this really is up to you as to how you wish to use it, but it is generally frowned upon on using redirects with form validation and flash variables.

Another approach would be to keep the mains controller the way it is, post to the login controller and copy the mains content into the index function of the controller. That way the main page still works the same, the login page will only show on failure, the downside is you have two copies of the same code, which makes for some headaches when dealing with revisions.
#29

[eluser]dadamssg[/eluser]
yeah this is getting really confusing because i have a working site using no framework thats pretty involved. And now im trying to recreate it using codeigniter. What i'm really trying to do is create a login form to display if they're not logged in and if they are a link to their profile, inbox, and notifications. I want to display this at the top of every page so i thought i would do it like this..

*this isnt a working example just my theory

for my mains controller

Code:
&lt;?php

class Mains extends Controller {

    function Mains()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('date');
        $this->load->helper('text');
        $this->load->helper('form');
        $this->load->library('session');
        $this->load->library('form_validation');
    }

    function index()
    {
        $data['title'] = "Home";
        $data['heading'] = "All Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_all_events();
        
        $this->load->view('header_view', $data);



                if(logged in)
                {///load the login form in the header
        $this->load->view('login_view', $data);
        }
                else
                {//load the logged in portion with the profile/inbox/notification links
                 $this->load->view('logged_view', $data);
                }

                //then load the main content
        $this->load->view('main_view', $data);
    }
    
    function performance()
    {
        $data['title'] = "Performance";
        $data['heading'] = "Performance Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_category_events('performance');
        
        $this->load->view('header_view', $data);

if(logged in)
                {///load the login form in the header
        $this->load->view('login_view', $data);
        }
                else
                {//load the logged in portion with the profile/inbox/notification links
                 $this->load->view('logged_view', $data);
                }

                //then load the main content

        $this->load->view('main_view', $data);    
    }
    
    function sports()
    {
        $data['title'] = "Sports";
        $data['heading'] = "Sports Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_category_events('sports');
        
        $this->load->view('header_view', $data);

if(logged in)
                {///load the login form in the header
        $this->load->view('login_view', $data);
        }
                else
                {//load the logged in portion with the profile/inbox/notification links
                 $this->load->view('logged_view', $data);
                }

                //then load the main content

        $this->load->view('main_view', $data);    
    }
    function organization()
    {
        $data['title'] = "Organizational";
        $data['heading'] = "Organization Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_category_events('organization');
        
        $this->load->view('header_view', $data);

if(logged in)
                {///load the login form in the header
        $this->load->view('login_view', $data);
        }
                else
                {//load the logged in portion with the profile/inbox/notification links
                 $this->load->view('logged_view', $data);
                }

                //then load the main content

        $this->load->view('main_view', $data);    
    }
    function random()
    {
        $data['title'] = "Random";
        $data['heading'] = "Random Events";
        $this->load->model('Frontmodel');
        $data['query'] = $this->Frontmodel->get_category_events('random');
        
        $this->load->view('header_view', $data);

if(logged in)
                {///load the login form in the header
        $this->load->view('login_view', $data);
        }
                else
                {//load the logged in portion with the profile/inbox/notification links
                 $this->load->view('logged_view', $data);
                }

                //then load the main content

        $this->load->view('main_view', $data);    
    }
}

?&gt;
#30

[eluser]JHackamack[/eluser]
A few suggestions:

move: if(logged in)
{///load the login form in the header
$this->load->view('login_view', $data);
}
else
{//load the logged in portion with the profile/inbox/notification links
$this->load->view('logged_view', $data);
}
into your header_view file

so you don't have to deal with it every function (and makes changes easier)

Unless you're going to be doing alot with the login controller i wouldn't see the harm in moving the login function to the mains as long as everytime a user loges in they are always directed to the mains/index function (or something similar)




Theme © iAndrew 2016 - Forum software by © MyBB