php - getting id from POST request -
i'm watching tutorial i'm watching tutorials cms oop - php
on control page :
public function update() { if(isset($_post['updatearticle'])) { $id = (int)$_post['id']; //article data array //varaibles $title = $_post['title']; //title $content= $_post['content']; //content $cat = (int)$_post['cat']; //validation //data array $data = array( 'title' => $title, 'content' => $content, 'cid' => $cat ); //insert if($this->articlesmodel->update($id,$data)) { system::get('tpl')->assign('message','article updated'); system::get('tpl')->draw('success'); } else { system::get('tpl')->assign('message','error updating article'); system::get('tpl')->draw('error'); } } else { $id = 0 ; //init if(isset($_get['id']) && (int)$_get['id'] > 0) { $id = (int)$_get['id']; //get article db $article = $this->articlesmodel->get_by_id($id); if(count($article)>0) { //categories $cats = $this->articlescatsmodel->get(); //article found system::get('tpl')->assign($article); system::get('tpl')->assign('cats',$cats); system::get('tpl')->draw('updatearticle'); } else { //article not found system::get('tpl')->assign('message','article not found'); system::get('tpl')->draw('error'); } } else { //no id system::get('tpl')->assign('message','ivalid id'); system::get('tpl')->draw('error'); } } }
he id
post request how !!!
we take id url request
he did because of source
source of page:
<input type="hidden" name="id" value="5" /> <input type="submit" class="btn btn-info" name="updatearticle" value="update article" />
how can take id post request !!
and if changed request error
html form tag has method
attribute. attribute defines whether content sent using post or get.
check method of <form method=?>
.
Comments
Post a Comment