Simple form to save data to db - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Simple form to save data to db (/showthread.php?tid=65112) Pages:
1
2
|
Simple form to save data to db - meOmy - 04-30-2016 Hello, I'm a couple days into CodeIgniter 3.0 now and very frustrated; hence the reason for signing up with this forum. I have been scouring the web for simple examples of how to save data to a db using CI 3.0, but can't find anything that is either CI 3.0, that actually works, or that is all inclusive. Yes, the manual shows some examples of working with db's, but doesn't put it all together for you using M, V, & C files; at least not that I've seen. So, I'm asking if someone would be generous enough to either point me in the direction of a tut that uses: CI 3.0, all M,V, & C, and proper security implementation (sql inject proof) for submitting a few form fields to a db. If you don't have any link that would meet all those requests, would you consider providing simple MVC files that show me how to submit to a db: 1 textbox 1 listbox (i.e. menu select, drop down menu) 1 checkbox 1 textarea w/ Submit button using one or two validations and anything else you like to use that you feel makes your submission more secure from an sql injection. I learn very well when I'm able to see something and feel I can get a great start building on what you've given me if I just had a simple example to follow to get started with. Thank you very much to anyone willing to take a little time to help. RE: Simple form to save data to db - InsiteFX - 04-30-2016 You can find examples that use forms in just about all the auth system that built for CI. RE: Simple form to save data to db - Wouter60 - 04-30-2016 Model: PHP Code: <?php Controller: PHP Code: <?php View: PHP Code: <?php That's a basic setup based on MVC in CI. RE: Simple form to save data to db - Code4fun - 04-30-2016 You can take a look at my weblog application (see signature) and use it as a starting point to learn more about CodeIgniter? RE: Simple form to save data to db - meOmy - 04-30-2016 (04-30-2016, 11:10 AM)Wouter60 Wrote: Model: Thank you. Can you please confirm this is working on CI 3.0 because I'm getting fatal errors and notices. Also, what were the file names? Thank you again! RE: Simple form to save data to db - Wouter60 - 04-30-2016 All models, controllers and libraries in CI 3.x must start with a capital letter. In my example: application/models/Test_model.php application/controllers/Testcontroller.php Views are in lowercase: application/views/test_view.php If you load a model or library, with $this->load->model(...), then you don't use capital letters. Information about the differences between 2.x en 3.x is here: http://www.codeigniter.com/user_guide/installation/upgrade_300.html RE: Simple form to save data to db - meOmy - 05-06-2016 (04-30-2016, 04:06 PM)Code4fun Wrote: You can take a look at my weblog application (see signature) and use it as a starting point to learn more about CodeIgniter? Thank you. I downloaded/installed it and only the homepage works. All other links are broken for me. RE: Simple form to save data to db - Code4fun - 05-06-2016 Quote:I downloaded/installed it and only the homepage works. All other links are broken for me. Edit $config['base_url'] = ''; and remove index.php from $config['index_page'] = 'index.php'; in your config file. RE: Simple form to save data to db - meOmy - 05-06-2016 (05-06-2016, 05:29 PM)Code4fun Wrote:Quote:I downloaded/installed it and only the homepage works. All other links are broken for me. ..was already removed. RE: Simple form to save data to db - meOmy - 05-09-2016 (05-06-2016, 05:31 PM)meOmy Wrote:(05-06-2016, 05:29 PM)Code4fun Wrote:Quote:I downloaded/installed it and only the homepage works. All other links are broken for me. Code4fun: Hi, I've done as you suggested with the config file in terms of base URL and index.php, but still no luck. I'm beginning to believe the issue is perhaps tied to the base URL. When I go to your project's homepage, your site is there, but when I place my mouse over the NEWS, CONTACT, etc links, the base URL is displayed differently/incorrectly. I currently have: http://localhost/CI/ in my config and your homepage comes up fine When I mouse over links stated above, I get: localhost/news localhost/contact ... instead of: localhost/CI/news localhost/CI/contact ... which, by the way, work when I manually type them in I'm using UniServer 11.8.2, but don't feel like that's the issue; although it might be. I just don't know. I tried moving your files to localhost/CI/Test to see if that might work, but I get the exact same issue as stated above. Do you have any special .htaccess or index.php configurations that I might not have? Hoping someone can help, so I can get started learning more about CI. thank you! EDIT: Also, when I add "CI" to the following menu in your theme: {menudata} <a class="blog-nav-item {active}" href="CI{link}">{name}</a> {/menudata} ... I get localhost/CI/CI/news |