Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- html>
- <head>
- <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.png">
- <meta charset="utf-8">
- <title>CloudSystem</title>
- <style>
- #user_info{
- position: absolute;
- top: 40%;
- left: 35%;
- }
- #pwd_info{
- position: absolute;
- top: 45%;
- left: 35%;
- }
- #user_field{
- position: absolute;
- top: 40%;
- left: 43%;
- }
- #pwd_field{
- position: relative;
- top: 45%;
- left: 43%;
- }
- #login_btn{
- position: absolute;
- top: 50%;
- left: 55%;
- }
- </style>
- <script>
- </script>
- </head>
- <body>
- <form method="post" action="login.php">
- <div id="user_info">
- <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>
- </div>
- <div id="pwd_info">
- <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>
- </div>
- <div id ="login_btn">
- <input style="height: 25px; width: 50px;" type="submit" name ="login" value="Login" onclick="call()">
- </div>
- </form>
- <?php
- $datafolder = $_SERVER['DOCUMENT_ROOT'];
- include($datafolder.'/mysql/mysql-connection.php');
- $conn = mysqli_connect($mysqlservername, $mysqlusername, $mysqlpassword, $mysqldatabase);
- if(!$conn){
- exit("Verbindungsfehler: ".mysqli_connect_error());
- }else{
- $select1 = "SELECT Username FROM CloudWebLogin WHERE ID=0";
- $result = $conn->query($select1);
- if ($result->num_rows <= 0) {
- //Create Table entry
- $create = "CREATE TABLE IF NOT EXISTS CloudWebLogin(ID INT(6), Username VARCHAR(100), Password VARCHAR(100), Email VARCHAR(100))";
- if ($conn->query($create) === TRUE) {
- $insert = "INSERT INTO CloudWebLogin (ID, Username, Password, Email) VALUES (0, 'root', 'test123', 'test@example.com')";
- if ($conn->query($insert) === TRUE) {
- } else {
- echo "Error creating table: " . $conn->error;
- }
- } else {
- echo "Error creating table: " . $conn->error;
- }
- }else{
- }
- }
- if(isset($_POST['login'])){
- $user = $_POST['user_info_txt'];
- $pwd = $_POST['pwd_info_txt'];
- $realpwd = "";
- $userexists = "SELECT Password FROM CloudWebLogin WHERE Username='".$user."'";
- $userresult = $conn->query($userexists);
- if ($userresult->num_rows > 0) {
- while($row = $userresult->fetch_assoc()) {
- $realpwd = $row["Password"];
- }
- if($realpwd === $pwd){
- $url = "http://".$_SERVER['HTTP_HOST']."/acp/start.php";
- header("location: ".$url);
- }else{
- //invalid password
- }
- }else{
- //Invalid username
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement