-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
74 lines (73 loc) · 2.67 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
65
66
67
68
69
70
71
72
73
74
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="url shortener">
<title>smalr | URL Shortener</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<br>
<center>
<h1>smalr | URL Shortener</h1>
<?php
if (isset($_SESSION['success'])) {
echo "<p class='success'>" . $_SESSION['success'] . "</p>";
unset($_SESSION['success']);
}
if (isset($_SESSION['error'])) {
echo "<p class='alert'>" . $_SESSION['error'] . "</p>";
unset($_SESSION['error']);
}
if (isset($_GET['error']) && $_GET['error'] == 'db') {
echo "<p class='alert'>Error in connecting to database!</p>";
}
if (isset($_GET['error']) && $_GET['error'] == 'inurl') {
echo "<p class='alert'>Not a valid URL!</p>";
}
if (isset($_GET['error']) && $_GET['error'] == 'dnp') {
echo "<p class='alert'>Ok! So I got to know you love playing! But don't play here!!!</p>";
}
?>
<form method="POST" action="functions/shorten.php">
<div class="section group">
<div class="col span_3_of_3">
<input type="url" id="input" name="url" class="input" placeholder="Enter a URL here">
</div>
<div class="col span_1_of_3">
<input type="text" id="custom" name="custom" class="input_custom" placeholder="Enable custom text"
disabled>
</div>
<div class="col span_2_of_3">
<div class="onoffswitch">
<input type="checkbox" name="customcheck" class="onoffswitch-checkbox" id="myonoffswitch"
onclick="toggle()">
<label class="onoffswitch-label" for="myonoffswitch"></label>
</div>
</div>
</div>
<input type="submit" value="Go" class="submit">
</form>
<script>
function toggle () {
if (document.getElementById('myonoffswitch').checked) {
document.getElementById('custom').placeholder = 'Enter your custom text'
document.getElementById('custom').disabled = false
document.getElementById('custom').focus()
}
else {
document.getElementById('custom').value = ''
document.getElementById('custom').placeholder = 'Enable custom text'
document.getElementById('custom').disabled = true
document.getElementById('custom').blur()
document.getElementById('input').focus()
}
}
</script>
</body>
</html>