Data is inserting Repeatedely when i click refresh. |
[eluser]Dinesh Viswanath[/eluser]
Hello All, I'm new to CI, But learning as quick as possible. Now, I'm developing an News Board Application. In this i'll add news & update it. Code: class NewsController extends Controller { For adding News, My URL will looks like - <b>http://localhost/index.php/newcontroller/addnews</b>. After successfully adding Data to the Database I’m calling the Index () function. But URL is remaining same as <b>http://localhost/index.php/newcontroller/addnews. <br>Once when i Press "REFRESH" Button Data is Repeatedly Inserting into database. I wanted to have U</b>RL looks like <b>http://localhost/index.php/newscontroller</b> So that Data won’t be inserted with out necessary. Pls tell some way to control this Refresh problem.
[eluser]cideveloper[/eluser]
Instead of using Code: self::index(); why dont you use Code: redirect('/newscontroller/', 'refresh'); as long as nothing is being written to the browser this will work. See the link below http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]Thorpe Obazee[/eluser]
You could use sessions to 'remember' that the same user(or anything) has inserted data then prevent it.
[eluser]Thorpe Obazee[/eluser]
[quote author="slowgary" date="1240991746"]Why not just stop clicking refresh? ;-)[/quote] Prevention is better than cure?
[eluser]Dinesh Viswanath[/eluser]
A perfect Design should forgive even when user commits mistake unknowingly. @bargainph well said...
|
Welcome Guest, Not a member yet? Register Sign In |