-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
64 lines (55 loc) · 1.73 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/index.css">
<title>Breakout</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="username" placeholder="Name" class="username" required>
<br><br>
<input type="submit" name="submit" value="-START-" class="submit"><br>
<a href="record.php">-RECORD-</a>
</form>
<?php
/**
* PHP version 5.6.31
* Check post data and save in session
*
* @category None
* @package None
* @author comi.hu <[email protected]>
* @license PHP License
* @link None
*/
require_once 'php/lib.php';
$postData = $_POST;
if (!empty($postData)) {
if (isset($postData["username"])) {
$username = convertInput($_POST["username"]);
if (strlen($username) > 0 && strlen($username) <= 20) {
session_start();
$_SESSION["username"] = $username;
$_SESSION["loginTS"] = time();
header("location:main.php");
} else {
echo '<script>alert("valid name");</script>';
}
}
}
?>
<script>
var usernameElement = document.querySelector(".username");
usernameElement.addEventListener('keyup', () => {
var username = usernameElement.value;
console.log(username);
if(username.length > 20) {
usernameElement.value = usernameElement.value.substr(0, 20);
}
});
</script>
</body>
</html>