Using Form to Insert data into Table -- please help |
[eluser]JPrieto[/eluser]
I really want to use the MVC programing struction of CI I learn best by example thats how I learn the pagination feature someone here was kind enough to provide code Now ... I would like to know if someone can provide me the code for a very simple form to insert data into a table which only has 3 fields please the idea is to use a form (using CI from validations, and strct CI form tags) to insert data into my database table NOTE: each entry must be check to make sure each username field value is unique the same for phone field -- both must be unique. I really want to use a model to insert data into the table here are the facts ================================= Database = friendsdb table name = "friends" table fields are: id - enumrates username - must be unique phone - also must be unique notes - text ================================== So.. if someone can provide the ..... #1 CODE FOR THE CONTROLLER (which we can call "Buddies") #2 CODE FOR THE FORM ENTRY #3 CODE FOR THE FORM SUCCESS PAGE #4 CODE FOR THE MODEL Please -- I really would be grateful Thanks ps: please test your code before submitting, as I will use to learn, and if there is any bug it will confuse me.
[eluser]depthcharge[/eluser]
Hi Jpriesto, You really can find great examples of all these solutions if you search the forums. I agree on learning by example, and the current offerings of code in the ignited code area, and wiki are great resources to learn by example.
[eluser]JPrieto[/eluser]
hi i cant find -- anywhere -- of any ci tags that checks and prevent double entries for example, how do you prevent a user_name from being entered twice i can code it in regular php but how can ci make it easier?
[eluser]depthcharge[/eluser]
You will not find a double_entry check routine built into codeigniter, that's functionality that we ourselves have to develop/extend. However it's very probable that 1 of the existing auth libraries has this built in. Quote:i can code it in regular php The only difference to regular php is that you will be using codeigniter's database functionality and organising your code into mvc. Perhaps using a form validation callback to check database for current username. Quote:but how can ci make it easier? App layout / organisation / less code due to use of existing base libraries etc.
[eluser]freshface[/eluser]
See the documentation, everything you ask is explained in it + examples.
[eluser]n0xie[/eluser]
If you follow the example in the usererguide you should be on your way. To check if an username already exists you could write a callback. The callback could pass the username to a model, which checks if the username is already present in the database. This way if you ever needed this function again, you already have the code ready for reuse. |
Welcome Guest, Not a member yet? Register Sign In |