· 8 years ago · Jun 22, 2018, 05:10 PM
1html>
2 <head>
3
4 <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.png">
5
6 <meta charset="utf-8">
7 <title>CloudSystem</title>
8
9 <style>
10
11 #user_info{
12 position: absolute;
13 top: 40%;
14 left: 35%;
15 }
16
17 #pwd_info{
18 position: absolute;
19 top: 45%;
20 left: 35%;
21 }
22
23 #user_field{
24 position: absolute;
25 top: 40%;
26 left: 43%;
27 }
28
29 #pwd_field{
30 position: relative;
31 top: 45%;
32 left: 43%;
33 }
34
35 #login_btn{
36 position: absolute;
37 top: 50%;
38 left: 55%;
39
40 }
41
42
43 </style>
44
45 <script>
46 </script>
47
48 </head>
49
50
51 <body>
52
53 <form method="post" action="login.php">
54 <div id="user_info">
55 <p style="color: black; background-color: whitesmoke; font-size: 130%"> Username: <input type="text" name="user_info_txt" value="" style="color: black; background-color: lightyellow; font-size: 100%"> </p>
56 </div>
57
58 <div id="pwd_info">
59 <p style="color: black; background-color: whitesmoke; font-size: 130%"> Password: <input type="password" name="pwd_info_txt" value="" style="color: black; background-color: lightyellow; font-size: 100%"> </p>
60 </div>
61
62 <div id ="login_btn">
63 <input style="height: 25px; width: 50px;" type="submit" name ="login" value="Login" onclick="call()">
64 </div>
65 </form>
66
67 <?php
68
69 $datafolder = $_SERVER['DOCUMENT_ROOT'];
70 include($datafolder.'/mysql/mysql-connection.php');
71
72
73 $conn = mysqli_connect($mysqlservername, $mysqlusername, $mysqlpassword, $mysqldatabase);
74 if(!$conn){
75 exit("Verbindungsfehler: ".mysqli_connect_error());
76 }else{
77 $select1 = "SELECT Username FROM CloudWebLogin WHERE ID=0";
78 $result = $conn->query($select1);
79
80 if ($result->num_rows <= 0) {
81 //Create Table entry
82 $create = "CREATE TABLE IF NOT EXISTS CloudWebLogin(ID INT(6), Username VARCHAR(100), Password VARCHAR(100), Email VARCHAR(100))";
83
84 if ($conn->query($create) === TRUE) {
85 $insert = "INSERT INTO CloudWebLogin (ID, Username, Password, Email) VALUES (0, 'root', 'test123', 'test@example.com')";
86
87 if ($conn->query($insert) === TRUE) {
88
89 } else {
90 echo "Error creating table: " . $conn->error;
91 }
92 } else {
93 echo "Error creating table: " . $conn->error;
94 }
95 }else{
96
97 }
98 }
99
100 if(isset($_POST['login'])){
101 $user = $_POST['user_info_txt'];
102 $pwd = $_POST['pwd_info_txt'];
103 $realpwd = "";
104
105 $userexists = "SELECT Password FROM CloudWebLogin WHERE Username='".$user."'";
106 $userresult = $conn->query($userexists);
107
108 if ($userresult->num_rows > 0) {
109 while($row = $userresult->fetch_assoc()) {
110 $realpwd = $row["Password"];
111 }
112
113 if($realpwd === $pwd){
114 $url = "http://".$_SERVER['HTTP_HOST']."/acp/start.php";
115 header("location: ".$url);
116 }else{
117 //invalid password
118 }
119
120 }else{
121 //Invalid username
122 }
123
124 }
125
126 ?>
127
128 </body>
129</html>