On edit form accept id and character as primary key


#1

Eg. http://example.org/articles/edit/5

this url fetch the record which has primary key 5, but in following url

http://example.org/articles/edit/5dsadasd

this is also get same record but i pass primary key 5dsadasd.

Please tell me How to prevent them ??


#2

ib db,

id colum is INT?
in cakephp did you create form, controller and model with cake bake tools?


#3

yes column is int type.


#4

I think you need to modify the routing for that like below:
$routes->connect(’/articles/edit/:id’, [‘controller’ => ‘Articles’,‘action’=>‘edit’],[‘id’ => ‘[0-9]’, ‘pass’ => [‘id’]]);

Try this and let me know is it working or not.