{"id":3306,"date":"2014-06-24T19:54:39","date_gmt":"2014-06-24T19:54:39","guid":{"rendered":"http:\/\/webninjataylor.com\/library\/?p=3306"},"modified":"2014-06-24T22:01:59","modified_gmt":"2014-06-24T22:01:59","slug":"basic-restricted-pages-with-php","status":"publish","type":"post","link":"https:\/\/webninjataylor.com\/library\/basic-restricted-pages-with-php\/","title":{"rendered":"Basic Restricted Pages with PHP"},"content":{"rendered":"<ol>\n<li>Create database with tables (at least 2 with 1 being for users)<\/li>\n<li>Create a user with limited privledges to the database<\/li>\n<li>Create a connection file using the new user<\/li>\n<li>Use the following on the main public page to ensure no sessions are currently active\n<pre>\/\/CALL SESSION AND DESTROY\r\nsession_start();\r\nunset($_SESSION);\r\nsession_destroy();<\/pre>\n<\/li>\n<li>Create a loginfailed page<\/li>\n<li>Create a login page which posts to a login_processor page (can use same code from sample with minor edits for correct variables) and point the form to action=&#8221;&lt;?php echo $loginFormAction; ?&gt;&#8221;<\/li>\n<li>On any page you want locked down, call the access script include<\/li>\n<li>For logout, set any link to href=&#8221;&lt;?php echo $logoutAction ?&gt;&#8221;&gt;<\/li>\n<li>Create manage, add, delete, edit, edit_processor, and logout (can use same code from sample with minor edits for correct variables)&#8230; be sure to use the following on all restricted pages&#8230;\n<pre>\/\/IF NOT LOGGED IN, GO TO LOGIN\r\nsession_start();\r\nif (!isset($_SESSION['access'])){\r\n    header(\"Location: login.php\");\r\n}<\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Create database with tables (at least 2 with 1 being for users) Create a user with limited privledges to the database Create a connection file using the new user Use the following on the main public page to ensure no sessions are currently active \/\/CALL SESSION AND DESTROY session_start(); unset($_SESSION); session_destroy(); Create a loginfailed page [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[144],"tags":[6],"class_list":["post-3306","post","type-post","status-publish","format-standard","hentry","category-web-shots","tag-php"],"_links":{"self":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/comments?post=3306"}],"version-history":[{"count":4,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3306\/revisions"}],"predecessor-version":[{"id":3404,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3306\/revisions\/3404"}],"wp:attachment":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/media?parent=3306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/categories?post=3306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/tags?post=3306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}