Question with small test script |
[eluser]Solarpitch[/eluser]
Hey guy's, I'm still new to CI so just playing around with different functions at the moment. One thing I'm trying to understand is a login script. I've set up this test script to help me understand. Here I'm basically calling the index page of the application which will load the login form. I have the form submitting to the same page.. Code: <?php echo form_open('index'); ?> But when I load the index page it still seems to preform the function as if it was submitted and prints my error "Invalid Name". So when I got direct to the url it will always print this message even if the user has not tried to log in. If someone could take a look and point me in the right direction, that would be great. Code: <?php login_form/form.php... Code: <?php echo $msg;?>
[eluser]therealmaloy[/eluser]
solarpitch please be reminded that the post variables can only be propagated properly once you have properly posted data/information from your submitted form. let's try to see the complete form submission view code you have. the statement below will never get any value, not unless, you have posted/inputted the value for username text input control before submission: $username = $this->input->post('username');
[eluser]anggie[/eluser]
Hmm...I tried to understand your explanation and here some suggestion for you.. you should change your code to Code: if($username=='') // not isset
[eluser]Solarpitch[/eluser]
Hi, Here's the complete submission view. Code: <?php echo validation_errors(); ?> See... the form above will submit to the index function in my controller, so why cant I use that function to get the variables being posted and then later... pass to my model? Do I need to create a seperate function called process or something to handle the submission... can I not handle the submission with the same index function?
[eluser]Solarpitch[/eluser]
Quote:the statement below will never get any value, not unless, you have posted/inputted the value for username text input control before submission: I should mention that $username is being passed a value as I'm able to print it to screen after a submission
[eluser]Henry Weismann[/eluser]
[quote author="Solarpitch" date="1229976144"] Quote:the statement below will never get any value, not unless, you have posted/inputted the value for username text input control before submission: I should mention that $username is being passed a value as I'm able to print it to screen after a submission[/quote] I think anggie is correct. It will receive a value of an empty string or false I forget which one. Either way isset will return true for both cases. It is not the same as the actual post array where you would use isset on a post array item.
[eluser]Henry Weismann[/eluser]
If it is passed a value what value does it have when you print it? You should learn the data validation class and it will save you tons of time and headaches. |
Welcome Guest, Not a member yet? Register Sign In |