masputhut Posted September 6, 2021 Share Posted September 6, 2021 Hello all members, I want to ask about PHP Native Sorry I'm new to PHP, I created an input form using Edit Text and Combobox But failed in saving the following is the code that I use The problem is I can't get the id from the combobox and it always fails to save it, :( function save_upload(){ extract($_POST); // var_dump($_FILES); $data = " title ='$title' "; $data .= ", description ='".htmlentities(str_replace("'","’",$description))."' "; $data .= ", user_id ='{$_SESSION['login_id']}' "; $data .= ", file_json ='".json_encode($fname)."' "; $data = " DocType_id ='$combodoctype' "; $data = " Dept_ID ='$combo4' "; if(empty($id)){ $save = $this->db->query("INSERT INTO documents set $data "); }else{ $save = $this->db->query("UPDATE documents set $data where id = $id"); } if($save){ return 1; } } admin_class.txt ajax.txt newdocument.txt Quote Link to comment https://forums.phpfreaks.com/topic/313671-newbie-ask-combobox-get-value-and-save/ Share on other sites More sharing options...
ginerjm Posted September 6, 2021 Share Posted September 6, 2021 Since you are discussing the inputs from a POST call, it might help to see the real html code. Extract is not normally used also. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313671-newbie-ask-combobox-get-value-and-save/#findComment-1589687 Share on other sites More sharing options...
Strider64 Posted September 6, 2021 Share Posted September 6, 2021 Warning Do not use extract() on untrusted data, like user input (e.g. $_GET, $_FILES). This coming from https://www.php.net/manual/en/function.extract.php Quote Link to comment https://forums.phpfreaks.com/topic/313671-newbie-ask-combobox-get-value-and-save/#findComment-1589696 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.