generated from daytonaio/Sample-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
57 lines (56 loc) · 1.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Shortener</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.container {
max-width: 600px;
margin-top: 50px;
}
.url-form {
background: #f8f9fa;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 15px rgba(0,0,0,0.1);
}
.result {
margin-top: 20px;
padding: 15px;
border-radius: 5px;
}
.copy-button {
margin-top: 10px;
display: none;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center mb-4">URL Shortener</h1>
<div class="url-form">
<form action="shorten.php" method="POST">
<div class="mb-3">
<label for="long_url" class="form-label">Enter your URL:</label>
<input type="url" class="form-control" id="long_url" name="long_url" required
placeholder="https://example.com">
</div>
<button type="submit" class="btn btn-primary w-100">Shorten URL</button>
</form>
</div>
<div id="result" class="result"></div>
<button onclick="copyToClipboard()" class="btn btn-secondary w-100 copy-button" id="copyButton">
Copy Shortened URL
</button>
</div>
<script>
function copyToClipboard() {
const shortUrl = document.querySelector('.alert-link');
navigator.clipboard.writeText(shortUrl.href);
alert('URL copied to clipboard!');
}
</script>
</body>
</html>