{"id":1291,"date":"2022-08-30T15:15:18","date_gmt":"2022-08-30T15:15:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/undefined-index-btn_saveerror-in-php-closed-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:18","modified_gmt":"2022-08-30T15:15:18","slug":"undefined-index-btn_saveerror-in-php-closed-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/undefined-index-btn_saveerror-in-php-closed-collection-of-common-programming-errors\/","title":{"rendered":"Undefined index: btn_save&hellip;error in php [closed]-Collection of common programming errors"},"content":{"rendered":"<p>You might have something like this in your script:<\/p>\n<pre><code>$btn_save = $_GET['btn_save'];\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>$btn_save = $_POST['btn_save'];\n<\/code><\/pre>\n<p>You might replace it with:<\/p>\n<pre><code>$btn_save = (isset($_GET['btn_save']) ? $_GET['btn_save'] : null);\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>$btn_save = (isset($_POST['btn_save']) ? $_POST['btn_save'] : null);\n<\/code><\/pre>\n<p>accordingly<\/p>\n<p>At first time you run your script without ?btn_save=[something] and $_GET has no key like btn_save.<\/p>\n<p>However, it would be better to design a validator which will return error messages in cases like:<\/p>\n<ul>\n<li>Required field is empty<\/li>\n<li>The field should be numeric<\/li>\n<li>The field should be alpha-numeric<\/li>\n<li>etc<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:14:50. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>You might have something like this in your script: $btn_save = $_GET[&#8216;btn_save&#8217;]; or $btn_save = $_POST[&#8216;btn_save&#8217;]; You might replace it with: $btn_save = (isset($_GET[&#8216;btn_save&#8217;]) ? $_GET[&#8216;btn_save&#8217;] : null); or $btn_save = (isset($_POST[&#8216;btn_save&#8217;]) ? $_POST[&#8216;btn_save&#8217;] : null); accordingly At first time you run your script without ?btn_save=[something] and $_GET has no key like btn_save. However, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1291","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1291"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1291\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}