-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc.html
107 lines (98 loc) · 4.41 KB
/
c.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>تسجيل الدخول والتسجيل</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
}
.container {
max-width: 600px;
margin-top: 50px;
}
.form-group {
margin-bottom: 1.5em;
}
#result {
margin-top: 20px;
font-size: 1.2em;
color: red;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">تسجيل الدخول والتسجيل</h1>
<!-- نموذج تسجيل الدخول -->
<h2>تسجيل الدخول</h2>
<form id="loginForm">
<div class="form-group">
<input type="text" class="form-control" name="username" placeholder="اسم المستخدم" required>
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="كلمة المرور" required>
</div>
<button type="submit" class="btn btn-primary btn-block">تسجيل الدخول</button>
</form>
<!-- نموذج التسجيل -->
<h2 class="mt-5">تسجيل جديد</h2>
<form id="signupForm">
<div class="form-group">
<input type="text" class="form-control" name="new_username" placeholder="اسم المستخدم الجديد" required>
</div>
<div class="form-group">
<input type="password" class="form-control" name="new_password" placeholder="كلمة المرور الجديدة" required>
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirm_password" placeholder="تأكيد كلمة المرور" required>
</div>
<button type="submit" class="btn btn-success btn-block">تسجيل</button>
</form>
<!-- عرض النتائج -->
<div id="result"></div>
</div>
<script>
// معالجة تسجيل الدخول
document.getElementById("loginForm").onsubmit = function(event) {
event.preventDefault();
var username = event.target.username.value;
var password = event.target.password.value;
fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `username=${username}&password=${password}`
}).then(response => response.json()).then(data => {
document.getElementById("result").innerText = data.message || data.error || "عملية تسجيل الدخول كانت ناجحة!";
});
};
// معالجة التسجيل
document.getElementById("signupForm").onsubmit = function(event) {
event.preventDefault();
var new_username = event.target.new_username.value;
var new_password = event.target.new_password.value;
var confirm_password = event.target.confirm_password.value;
if (new_password !== confirm_password) {
document.getElementById("result").innerText = "كلمة المرور وتأكيد كلمة المرور لا تتطابق!";
return;
}
fetch('/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `username=${new_username}&password=${new_password}`
}).then(response => response.json()).then(data => {
document.getElementById("result").innerText = data.message || data.error || "عملية التسجيل كانت ناجحة!";
});
};
</script>
<!-- إضافة مكتبات Bootstrap و jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>