{"id":1599,"date":"2015-06-19T12:01:44","date_gmt":"2015-06-19T12:01:44","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=1599"},"modified":"2022-02-17T07:14:02","modified_gmt":"2022-02-17T07:14:02","slug":"simple-site-log-in","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/security\/simple-site-log-in","title":{"rendered":"Simple Site Log In Form"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"> In the head of each page add this<\/h4>\n\n\n\n<p>Note this must be before any html header are sent (i.e. in php code before html output)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/----- CHECK USER IS LOGGED IN -----\nsession_start();\nif ( (!isset($_SESSION&#91;'userisloggedin'])) || ($_SESSION&#91;'userisloggedin'] != \"YES\") )\n{\n\theader(\"Location: login.php\");\n\tdie();\n}\n?&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Use this as the log in page <\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/------------------------------------\n\/\/----- CHECK FOR FORM SUBMITTED -----\n\/\/------------------------------------\nsession_start();\nif ( (isset($_POST&#91;'action'])) &amp;&amp; ($_POST&#91;'action'] == \"log_user_in\") )\n{\n\tif (trim($_POST&#91;'Password']) == \"1234\")\n\t{\n\t\t$_SESSION&#91;'userisloggedin'] = \"YES\";\n\t\theader(\"Location: index.php\");\n  \tdie();\n\t}\n}\n?&gt;\n\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"&gt;\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/&gt;\n\n&lt;title&gt;Log In&lt;\/title&gt;\n\n&lt;style type=\"text\/css\"&gt;\n&lt;!--\nbody {\n\tfont-family: Arial, Helvetica, sans-serif;\n\tfont-size: small;\n\tcolor: #000033;\n}\n--&gt;\n&lt;\/style&gt;\n\n&lt;\/head&gt;\n\n&lt;body&gt;\n\t&lt;p&gt;Log In&lt;\/p&gt;\n&lt;?php\n\techo &lt;&lt;&lt;END\n\t\t &lt;form id=\"MyForm\" action=\"login.php\" method=\"POST\"&gt;\n\t\t\t\t&lt;input type=\"hidden\" name=\"action\" value=\"log_user_in\" \/&gt;\n\t\t\t\t&lt;p&gt;Password:&lt;\/p&gt;\n\t\t\t\t&lt;input type=\"text\" name=\"Password\" size=\"24\" autofocus &gt;&lt;\/input&gt;\n\t\t\t\t&lt;input type=\"submit\" value=\"Log In\" id=\"Send\" \/&gt;\t\t\t\t\t\n\t\t\t&lt;\/form&gt;\t\t\t\nEND;\n?&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Use this as an optional log out page<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nsession_start();\n$_SESSION&#91;'userisloggedin'] = \"NO\";\nheader(\"Location: index.php\");\ndie();\n?&gt;\n\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"&gt;\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/&gt;\n\n&lt;title&gt;Log Out&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the head of each page add this Note this must be before any html header are sent (i.e. in php code before html output) Use this as the log in page Use this as an optional log out page<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[289,42,34],"tags":[],"class_list":["post-1599","post","type-post","status-publish","format-standard","hentry","category-example-forms","category-forms","category-security"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=1599"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1599\/revisions"}],"predecessor-version":[{"id":3528,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/1599\/revisions\/3528"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=1599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=1599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=1599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}