Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $f = '';
- $data = array();
- if (isset($_GET['f'])){
- $f = $_GET['f'];
- }
- if ($f == 'test'){
- $data = array(
- "status" => 900
- );
- header("Content-type: application/json");
- echo json_encode($data);
- exit();
- }
- ?>
- <!doctype html>
- <html lang="de">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- .background{ width: 300px; height: 350px; background-color: white; position: absolute; left: 50%; top: 50%; margin-top: -175px; margin-left: -150px; border-radius: 50px; }
- .heading{text-align: center; font-size: 20pt;}
- .input{ width: 95%; border: none; margin-top: 20px; height: 38px; margin-left: 2.5%; }
- .loginBtn{ width: 100%; position: relative; height: 40px; margin-top: 15px; }
- </style>
- <script src="../imports/jQuery.js"></script>
- </head>
- <body>
- <div class="background">
- <div class="heading">Login</div>
- <form>
- <input class="input" type="text" id="username" placeholder="Username" />
- <input class="input" type="password" id="password" placeholder="Password" />
- <button type="button" class="loginBtn" onclick="tryLogin()" id="loginBtn">Login</button>
- </form>
- <div id="msg"></div>
- </div>
- </body>
- </html>
- <script>
- var username = "";
- var password = "";
- function tryLogin() {
- username = $("#username").val();
- password = $("#password").val();
- if (username != "") {
- if (password != "") {
- test(username, password);
- } else {
- $("#msg").html("Bitte gib ein Password ein.");
- }
- } else {
- $("#msg").html("Bitte gib einen Usernamen ein.");
- }
- }
- function test(username, password) {
- jQuery.ajax({
- url: 'http://localhost/request.php?f=test',
- type: 'POST',
- data: { username: username, password: password },
- dataType: 'json',
- success: function (data) {
- console.log(data);
- },
- error: function (jqXHR, textStatus, errorThrown) {
- console.log(jqXHR);
- console.log(textStatus);
- console.log(errorThrown);
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement