![]() |
[HELP] Form submitted even when empty. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [HELP] Form submitted even when empty. (/showthread.php?tid=72208) |
[HELP] Form submitted even when empty. - HarrysR - 11-20-2018 Hello, i have the following really serious problem with my register form. Here's the thing. I use jquery to load the register url in a div. Everything's ok so far. The BIG problem is that when i click submit, the form is submited and the ajax function is executed even if the inputs are empty. More over the field is filled with the action attributed even if i have it empty in my code. Here's the modal code (I pasted in pastebin cause its kinda big): https://pastebin.com/AdEpyAci Note: As you can see the attribute value is blank, but the form is still submitted. Model: Code: public function register($enc_password){ Controller: Code: public function create_user(){ It just drives me crazy.. The thing is that even though the input data are required, if they're empty the user can still register and have an empty - not valid profile url and empty data submitted in the db.. Any ideas? Thank you! RE: [HELP] Form submitted even when empty. - neuron - 11-20-2018 1. For form validation in front end you can use jquery validation library. 2. For user registering/login functions I suggest you to use Codeigniter Ion Auth Library. It has a lot of nice functionalities. 3. In CI backend form validation you should use CI form validation library. Ion Auth library uses it, you can extend your rules according to your needs RE: [HELP] Form submitted even when empty. - Wouter60 - 11-21-2018 I totally agree with neuron. Checking whether count($_POST) > 0 is not very useful. Empty fields and even the submit button itself are begin posted. CI's form validation will do the job for you. RE: [HELP] Form submitted even when empty. - HarrysR - 11-21-2018 Thank you guys! As i figured it out it was the boostrapValidator problem. I did something wrong there! I'll try your suggested ways though!! Thanks for your help! RE: [HELP] Form submitted even when empty. - HarrysR - 11-21-2018 (11-20-2018, 11:30 PM)neuron Wrote: 1. For form validation in front end you can use jquery validation library. As for the 2nd suggestion for using the Ion Auth Library. Since i'm kinda new in CI.. If i have a project which is online and has some users registered in it.. Is it possible to embed it later in the project? Without affecting the users experience and accounts? I hope you understand what i mean. RE: [HELP] Form submitted even when empty. - neuron - 11-22-2018 When I was new in CI, I implemented my own code to handle user registration and login. And after sometime more requirements for user actions occured. Then I coded some more to meet this requirement. But since I was beginner I made many mistakes and tried to fix it. This library failed login attemts, user activation by email, enable/disable user, more than one user groups (admin, user), brypt password hashing (I used md5 in my own implementation but later it is not secure enough anymore) remember me, and resetted when user changes password and more functionalities that I can't remember now. I mean you should use this library. If you are beginner you own implementation won't be as good as this library. You can integrate it later but I suggest you not to wait too long RE: [HELP] Form submitted even when empty. - HarrysR - 11-22-2018 (11-22-2018, 12:52 AM)neuron Wrote: When I was new in CI, I implemented my own code to handle user registration and login. I totally agree. My only concern is the users' passwords. I've had many people telling me to hash the passwords insteam of md5 and after some time I managed to hash them, but in order to implement the Ion Auth library in my project i want first to understand the code structure etc. since i use Ajax calls, modals for register, login etc.. so.. That's why i ask if it's possible to integrate it later. RE: [HELP] Form submitted even when empty. - neuron - 11-22-2018 You can update it as you wish, I edited it also to use for ajax requests |