Skip to content

Commit ee8fcc1

Browse files
committed
new lesson update 03-10-2020
1 parent f5d4b2b commit ee8fcc1

File tree

393 files changed

+98
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+98
-98
lines changed
File renamed without changes.

LESSON 33 - الدرس/app/admin/index.php

-53
This file was deleted.

LESSON 35 - الدرس/index.php

+48-45
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
1-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
2-
<?php
3-
// 1) connect to database - اتصال بقاعدة البيانات
4-
$username = "root";
5-
$password = "";
6-
$database = new PDO("mysql:host=localhost; dbname=codershiyar;",$username,$password);
7-
8-
9-
// 2) define how many results you want per page - تعريف عدد نتائج لكل صفحة
10-
$resultsPerPage = 10;
11-
12-
// 3) ايجاد عدد نتائج البيانات الذي تحدده من قاعدة البيانات
13-
// find out the number of results stored in database -
14-
$numberOfResults = $database->prepare("SELECT * FROM user_details ");
15-
$numberOfResults->execute();
16-
$numberOfResults = $numberOfResults->rowCount();
17-
18-
// 4) -تحديد رقم الصفحة الذي يعمل عليه الزائر حاليًا
19-
// determine which page number visitor is currently on
20-
if(!isset($_GET['page'])){
21-
$page = 1;
22-
}else if(isset($_GET['page'])){
23-
$page = $_GET['page'];
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Home</title>
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8+
9+
</head>
10+
<body>
11+
<!-- Image and text -->
12+
<nav class="navbar navbar-light bg-light">
13+
14+
<a class="navbar-brand" href="#">
15+
Coder Shiyar
16+
</a>
17+
18+
<img src="../img/logo.jpg" width="50" height="50" class="d-inline-block align-top" alt="" loading="lazy">
19+
20+
</nav>
21+
22+
<main class="container m-auto" style="max-width: 720px;">
23+
24+
<?php
25+
session_start();
26+
if(isset($_SESSION['user'])){
27+
if($_SESSION['user']->ROLE === "ADMIN"){
28+
echo '<div class="shadow p-3 mb-1 bg-white rounded mt-5"> Welcome ' .$_SESSION['user']->NAME . "</div>";
29+
echo '<a class="btn btn-light shadow w-100 mb-1" href="profile.php">تعديل ملف الشخصي</a>';
30+
echo '<a class="btn btn-light shadow w-100 mb-1" href="todolist.php">إضافة واجبات لقيام بها</a>';
31+
echo '<a class="btn btn-light shadow w-100 mb-1" href="search.php">إدارة المستخدمين</a>';
32+
33+
echo "<form> <button class='btn btn-danger w-100' type='submit' name='logout'>تسجيل خروج</button></form>";
34+
}else{
35+
header("location:http://localhost/App/login.php",true);
36+
die("");
2437
}
25-
// 5) determine number of total pages available - تحديد عدد الصفحات الإجمالية المتاحة
26-
27-
$totalPages = ceil($numberOfResults / $resultsPerPage) ;
28-
29-
for($count = 1; $count<= $totalPages; ++$count){
30-
if($page == $count){
31-
echo '<a style="color:black;" href="index.php?page='.$count.'">'.$count.'</a> ';
32-
}else{
33-
echo '<a href="index.php?page='.$count.'">'.$count.'</a> ';
34-
}
35-
38+
}else{
39+
header("location:http://localhost/App/login.php",true);
40+
die("");
3641
}
37-
// 6) تحديد رقم البداية المحدد للنتائج في صفحة العرض
38-
// determine the sql LIMIT starting number for the results on the displaying page
39-
40-
$results = $database->prepare("SELECT * FROM user_details LIMIT " . $resultsPerPage . " OFFSET " . ($page-1)*$resultsPerPage);
41-
$results->execute();
4242

43+
if(isset($_GET['logout'])){
44+
session_unset();
45+
session_destroy();
46+
header("location:http://localhost/App/login.php",true);
47+
}
48+
?>
49+
</main>
50+
</body>
51+
</html>
4352

44-
// 7) display the results - // عرض النتائج الصفحات
45-
46-
foreach($results AS $result){
47-
echo '<div class="shadow p-3 mb-3">'. $result['username'] . '</div>';
48-
}
4953

50-
?>
File renamed without changes.

0 commit comments

Comments
 (0)