Passing a view as a variable. |
[eluser]ellipsis[/eluser]
[quote author="Dam1an" date="1245456827"]First of all, the encrypt function 1) You're declaring it as a function within the constructor :-S 2) When calling a function, use $this->_encrypt instead of just _encrypt 3) It's setting the value in a local array called $fields, either make it return the encrypted value, or use a class variable for the array [/quote] I declared it up there because I thought that would help with my current error, but your suggestion did the trick ^_^ [quote author="Dam1an" date="1245456827"] As for the model, do you get any sort of errors with that? Or it just doesn't do anything? I just noticed, you don't ever seem to actually set the variabes you use in the formdata array?[/quote] I do get the errors now, because all the variables seem to be null. I wanted to set the values received from doing the form_validation in the array $formdata, but it seems it was the wrong way to go about doing that. Help?
[eluser]Dam1an[/eluser]
I think someone need to read up on the form validation library To get the values, you need to use set_value Code: $email = set_value('email);
[eluser]ellipsis[/eluser]
Well that's embarrassing, considering I've had the form validation page open for the past two days :lol: Anyway, that fixed that problem, now the only field that isn't going through to the db insert seems to be the password field... Here are the significant changes I've made: Code: function _encrypt($password) Code: $this->form_validation->set_rules('fn', 'First Name', 'trim|xss_clean');
[eluser]Dam1an[/eluser]
You still need to either return a value from the encrypt function and assign it to a variable which you then feed into the database, or class method
[eluser]ellipsis[/eluser]
That was incredibly stupid of me :lol: Thanks for that. I've successfully added my first user to the database Now on to the login script and dealing with sessions...
[eluser]Dam1an[/eluser]
Well done (and we all have stupid moments every now and again) Good luck with the login
[eluser]ellipsis[/eluser]
Now... I built a new controller Login for logging in, although the login will be done directly on the page you're on (i.e. you don't have to go to a log in page) and the user verification works, but I'm using redirect() to send the user to the home page. I was actually thinking of using a login function in the controller, but then I'd have to write it in each and every controller. Would it be better to write the function in, say, a model and then call it from every controller? Also, can I somehow tell redirect to go back to the current page?
[eluser]Dam1an[/eluser]
you could put the login code in a MY_Controller, that way it can be called from any page with no extra effort (you can either do the processing there, or call a library if you're prefer to wrap up all the authentication stuff in a library)
[eluser]ellipsis[/eluser]
[quote author="Dam1an" date="1245505980"]you could put the login code in a MY_Controller, that way it can be called from any page with no extra effort (you can either do the processing there, or call a library if you're prefer to wrap up all the authentication stuff in a library)[/quote] Is it possible to call a controller? like $this-controller_name->index() As far as I know, I have php 5 and method chaining should work, but the following fuction Code: function get_id($logindata) gives me the following error Quote:Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\xampp\htdocs\site\frontend\models\login_model.php on line 18
[eluser]Dam1an[/eluser]
are you rrefering to calling the controller from within MY_Controller? You don't need to It still calls the controller function as it would normally, but calls MY_Controller and it's constructor first Or you on about something completely differant? As for the second part, you have an extra -> after where and missing the $ in from of this on the next line, it should be Code: function get_id($logindata) { Also, you pass in $logindata and don;t use it, but get a $username variable from nowhere :-S Oh, and a decent IDE (I pasted it in Eclipse for it to tell me the syntax error) will save lots of time |
Welcome Guest, Not a member yet? Register Sign In |