Active Record "insert" is not working properly |
[eluser]Daksh Mehta[/eluser]
Hello friends, I am new to CI and developing my first application. I am using active record "insert" to insert a member into database from registration page, but its not working properly. The problem with active record is that , whenever i am using the insert(), its adding one extra record in it with values 0 for all fields. Here is my controller: Code: <?php the table will look like: ID username password email 1 dax abc [email protected] 2 0 0 0 where, the record with ID 2 is automatically added without execution any kind of query. My view is located in /views/default/register/process.php Code: {header} Please, let me know why its happening with solution.
[eluser]waynhall[/eluser]
I'd recommending using a model, not a controller, to perform database inserts. But I'm puzzled as to why you're getting the extra record.
[eluser]waynhall[/eluser]
I would try running a test view outside of the template parser. Create a new view that doesn't use the template. Just use <?php ?> tags, to determine if the template has something to do with this.
[eluser]InsiteFX[/eluser]
Maybe you should do a echo var_dump to see what is being put into your $sql array InsiteFX
[eluser]Daksh Mehta[/eluser]
Hello, thanks for your help but its still not working, i can't understand why its not working. here is my new process() function: Code: public function process(){ and here is my members.php model used in the above function: Code: <?php Its still inserting 2 rows.. I am not understanding why its not working. Actually, i have created one library for retrieving and saving setting of portals into the database, which is as follow: Code: <?php When we are accessing the add() function, its working fine and inserting only one row. Please, if possible experiment it practically and let me know what you say about it. Again thanks to all, looking forward for help!
[eluser]waynhall[/eluser]
Is it possible you are using javascript that is broken on the client side sending the null values via ajax just before the page submits?
[eluser]Daksh Mehta[/eluser]
yes, i am using Ajax to validate username if its available or not. that's it . And i am beginner, so i can judge it. Here is my js file: Code: user_validated = 0; Here is my ajax controller: Code: <?php
[eluser]waynhall[/eluser]
First of all, use the Web Developer Toolbar to disable javascript on the page. Does that fix the double insert problem?
[eluser]appleboy[/eluser]
double insert problem? Please referrer it http://ellislab.com/forums/viewthread/195128/
[eluser]Daksh Mehta[/eluser]
[quote author="appleboy" date="1312378191"]double insert problem? Please referrer it http://ellislab.com/forums/viewthread/195128/[/quote] Thanks. But its still not helping me.. Also, i have checked with Opera and Chrome, where its working perfectly without any problem. and inserting only one row. I have already tried to use return TRUE; in my model and disabled js on browser and even disabled all addon. still not working. hope i can resolve it as soon as possible.. |
Welcome Guest, Not a member yet? Register Sign In |