8 <div class="col-12" style="background-image: url('img/header-bg.jpg');">
9 <div class="tm-brand-container text-left">
10 <p class="tm-brand-description mb-0">
11 <font COLOR="#FFFFFF">
12 <BIG><myPHP></BIG>
13 <SMALL><BR>free PHP scripts</SMALL>
14 </font>
15 </p>
16 </div>
17 </div>
18 </div>
19 </div>
20</section>
21<!-- End Welcome section -->
22
23<!-- Portfolio section -->
24<section id="tmPortfolio">
25 <div class="container-fluid">
26 <div class="row">
27 <div class="col-12">
28 <SMALL>
29 <H2><SMALL>Simple Login System with PHP</SMALL></H2>
30
31 Simple login system is a login form is what your can use to login to your website to access restricted content,
32 like a adminpage, With this script you don't need MySqli, But it has i't limits. with this scipt you can only have 1 user.
33 <BR><BR>
34 Okej lefts begin.<BR><BR>
35
36 First you need to create 2 pages "index.php" and "secretpage.php" <BR><BR>
37
38 The "index.php" file
39
40 <div class="code">
41<PRE>
42<I STYLE="color:blue">
43<?php
44$usererror = "";
45$passerror = "";
46
47if(isset($_POST['submit']))
48{
49 $user = "admin"; <I STYLE="color:green">// change username</I>
50 $pass = "gh3dgue7sber"; <I STYLE="color:green">// change password</I>
51 $page = "secretpage.php"; <I STYLE="color:green">// change secretpage</I>
52
53 $username = $_POST['username'];
54 $password = $_POST['password'];
55
56 if($username == $user) { $u_proceed = "1"; } else { $u_proceed = "0"; $usererror = "Wrong username !!!"; }
57 if($password == $pass) { $p_proceed = "1"; } else { $p_proceed = "0"; $passerror = "Wrong password !!!"; }
58
59 if($u_proceed == "1" && $p_proceed = "1")
60 {
61 $_SESSION['loggedin'] = 1;
62 header('Location: '.$page );
63 }
64}
65?>
66</I>
67
68<!DOCTYPE html>
69<html>
70 <head>
71 <meta charset="utf-8">
72 <title>Simple Login System / myPHP.se</title>
73 </head>
74 <body>
75<div align="center">
76 <div style="width: 330px;">
77 <h2>Easy Login System</h2>
78 <form action="index.php" method="post">
79 <input type="text" name="username" placeholder="Username" id="username" required><BR><i STYLE="color:blue"><?php echo $usererror;?></i><BR>
80 <input type="password" name="password" placeholder="Password" id="password" required><BR><i STYLE="color:blue"><?php echo $passerror;?></i><BR>
81 <input type="submit" value="Login" name="submit">
82 </form>
83 </div>
84 </div>
85 </body>
86</html>
87</PRE>
88 </div>
89
90 <BR>
91 The "secretpage.php" file
92
93 <div class="code">
94<PRE><I STYLE="color:blue">
95<?php
96session_start();
97
98if(!isset($_SESSION['loggedin'])) {
99 header('Location: index.php');
100 exit();
101}
102?>
103</I>
104<!DOCTYPE html>
105<html>
106 <head>
107 <meta charset="utf-8">
108 <title>SecretPage / myPHP.se</title>
109 </head>
110 <body>
111<H2>Secret page</H2>
112 </body>
113</html>
114</PRE>
115 </div>
116 <BR>
117
118 DOWNLOAD<BR>
119
120 <A HREF="zip/SimpleLoginSystem_myphp-se.zip"><IMG SRC="img/zip.png" WIDTH="32" HEIGHT="32" ALT=""> Simple Login System</A>
121 </SMALL><BR><BR><BR>
122 </div>
123 </div>
124 </div>
125</section>
126
127<?php
128include "footer.php";
129?>