mirror of
https://github.com/Alvin-Zilverstand/school.git
synced 2026-03-07 05:52:46 +01:00
add challenge 11(portifolio)
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
require_once '../php/config.php';
|
||||
|
||||
$message = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$title = $_POST['title'] ?? '';
|
||||
$description = $_POST['description'] ?? '';
|
||||
$long_description = $_POST['long_description'] ?? '';
|
||||
$project_url = $_POST['project_url'] ?? '';
|
||||
$tags = $_POST['tags'] ?? '';
|
||||
$image_url = '';
|
||||
// Handle image upload
|
||||
if (isset($_FILES['image_file']) && $_FILES['image_file']['error'] === UPLOAD_ERR_OK) {
|
||||
$ext = pathinfo($_FILES['image_file']['name'], PATHINFO_EXTENSION);
|
||||
$filename = uniqid('img_', true) . '.' . strtolower($ext);
|
||||
$target = '/var/www/alvnx.xyz/public_html/assets/' . $filename;
|
||||
if (move_uploaded_file($_FILES['image_file']['tmp_name'], $target)) {
|
||||
$image_url = 'assets/' . $filename;
|
||||
} else {
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Image upload failed.</div>';
|
||||
}
|
||||
} else if (!empty($_POST['image_url'])) {
|
||||
$image_url = $_POST['image_url'];
|
||||
}
|
||||
if (!$message) {
|
||||
try {
|
||||
$pdo = get_pdo();
|
||||
$stmt = $pdo->prepare('INSERT INTO projects (title, description, long_description, image_url, project_url, tags) VALUES (?, ?, ?, ?, ?, ?)');
|
||||
$stmt->execute([$title, $description, $long_description, $image_url, $project_url, $tags]);
|
||||
$message = '<div class="bg-green-100 text-green-800 p-3 rounded mb-4">Project added successfully!</div>';
|
||||
} catch (Exception $e) {
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Error: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Add Project</title>
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Tailwind CSS CDN -->
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
dark: {
|
||||
bg: '#0f172a',
|
||||
card: '#334155',
|
||||
text: '#f1f5f9'
|
||||
}
|
||||
},
|
||||
fontFamily: {
|
||||
'sans': ['Inter', 'system-ui', 'sans-serif'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="../css/styles.css">
|
||||
<link rel="stylesheet" href="../css/animations.css">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/svg+xml" href="../assets/favicon.svg">
|
||||
</head>
|
||||
<body class="min-h-screen flex items-center justify-center transition-colors duration-200">
|
||||
<!-- Back to home button -->
|
||||
<a href="../index.php" class="fixed top-6 left-6 btn-primary inline-flex items-center space-x-2 z-50 animate-bounce-in">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
||||
</svg>
|
||||
<span>Back to Home</span>
|
||||
</a>
|
||||
|
||||
<div class="bg-white dark:bg-dark-card p-8 rounded-2xl shadow-xl w-full max-w-2xl mx-4 transition-colors duration-200 border border-gray-200 dark:border-gray-600">
|
||||
<div class="flex justify-between items-center mb-8">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold mb-2 text-gray-800 dark:text-white">Add New Project</h1>
|
||||
<p class="text-gray-600 dark:text-gray-400">Create a new project for your portfolio</p>
|
||||
</div>
|
||||
<a href="index.php" class="text-gray-600 dark:text-gray-400 hover:underline font-medium px-4 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
||||
</svg>
|
||||
Back to Projects
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?= $message ?>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" class="space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Title *</label>
|
||||
<input type="text" name="title" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Project URL</label>
|
||||
<input type="text" name="project_url" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" placeholder="https://example.com">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Short Description</label>
|
||||
<textarea name="description" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" rows="3" placeholder="Brief description of your project"></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Long Description</label>
|
||||
<textarea name="long_description" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" rows="6" placeholder="Detailed description of your project, technologies used, challenges faced, etc."></textarea>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Image Upload</label>
|
||||
<input type="file" name="image_file" accept="image/*" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2">Upload an image file (JPG, PNG, GIF)</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Or Image URL</label>
|
||||
<input type="text" name="image_url" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" placeholder="assets/myimg.jpg">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2">Or provide a URL to an image</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Tags</label>
|
||||
<input type="text" name="tags" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" placeholder="HTML, CSS, JavaScript, React">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2">Separate tags with commas (e.g., HTML, CSS, JavaScript)</p>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 pt-4">
|
||||
<button type="submit" class="btn-primary px-8 py-3">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
||||
</svg>
|
||||
Add Project
|
||||
</button>
|
||||
<a href="index.php" class="text-gray-600 dark:text-gray-400 hover:underline font-medium px-8 py-3 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="../js/dark-mode.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
255
projects/challenge 11/portifolio(work_in_progress)/db/index.php
Normal file
255
projects/challenge 11/portifolio(work_in_progress)/db/index.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['logged_in']) || !$_SESSION['logged_in']) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
if (isset($_GET['logout'])) {
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
require_once '../php/config.php';
|
||||
|
||||
// Handle delete
|
||||
if (isset($_GET['delete'])) {
|
||||
$id = intval($_GET['delete']);
|
||||
try {
|
||||
$pdo = get_pdo();
|
||||
$pdo->prepare('DELETE FROM projects WHERE id = ?')->execute([$id]);
|
||||
$message = '<div class="bg-green-100 text-green-800 p-3 rounded mb-4">Project deleted.</div>';
|
||||
} catch (Exception $e) {
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Error: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_id'])) {
|
||||
$id = intval($_POST['edit_id']);
|
||||
$title = $_POST['title'] ?? '';
|
||||
$description = $_POST['description'] ?? '';
|
||||
$long_description = $_POST['long_description'] ?? '';
|
||||
$project_url = $_POST['project_url'] ?? '';
|
||||
$tags = $_POST['tags'] ?? '';
|
||||
$image_url = $_POST['image_url'] ?? '';
|
||||
// Handle image upload
|
||||
if (isset($_FILES['image_file']) && $_FILES['image_file']['error'] === UPLOAD_ERR_OK) {
|
||||
$ext = pathinfo($_FILES['image_file']['name'], PATHINFO_EXTENSION);
|
||||
$filename = uniqid('img_', true) . '.' . strtolower($ext);
|
||||
$target = '/var/www/alvnx.xyz/public_html/assets/' . $filename;
|
||||
if (move_uploaded_file($_FILES['image_file']['tmp_name'], $target)) {
|
||||
$image_url = 'assets/' . $filename;
|
||||
} else {
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Image upload failed.</div>';
|
||||
}
|
||||
}
|
||||
if (!$message) {
|
||||
try {
|
||||
$pdo = get_pdo();
|
||||
$stmt = $pdo->prepare('UPDATE projects SET title=?, description=?, long_description=?, image_url=?, project_url=?, tags=? WHERE id=?');
|
||||
$stmt->execute([$title, $description, $long_description, $image_url, $project_url, $tags, $id]);
|
||||
$message = '<div class="bg-green-100 text-green-800 p-3 rounded mb-4">Project updated.</div>';
|
||||
} catch (Exception $e) {
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Error: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch all projects
|
||||
try {
|
||||
$pdo = get_pdo();
|
||||
$projects = $pdo->query('SELECT * FROM projects ORDER BY created_at DESC')->fetchAll();
|
||||
} catch (Exception $e) {
|
||||
$projects = [];
|
||||
$message = '<div class="bg-red-100 text-red-800 p-3 rounded mb-4">Error: ' . htmlspecialchars($e->getMessage()) . '</div>';
|
||||
}
|
||||
|
||||
// If editing, fetch project
|
||||
$edit_project = null;
|
||||
if (isset($_GET['edit'])) {
|
||||
$id = intval($_GET['edit']);
|
||||
foreach ($projects as $p) {
|
||||
if ($p['id'] == $id) {
|
||||
$edit_project = $p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Manage Projects</title>
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Tailwind CSS CDN -->
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
dark: {
|
||||
bg: '#0f172a',
|
||||
card: '#334155',
|
||||
text: '#f1f5f9'
|
||||
}
|
||||
},
|
||||
fontFamily: {
|
||||
'sans': ['Inter', 'system-ui', 'sans-serif'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="../css/styles.css">
|
||||
<link rel="stylesheet" href="../css/animations.css">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/svg+xml" href="../assets/favicon.svg">
|
||||
</head>
|
||||
<body class="min-h-screen transition-colors duration-200">
|
||||
<!-- Back to home button -->
|
||||
<a href="../index.php" class="fixed top-6 left-6 btn-primary inline-flex items-center space-x-2 z-50 animate-bounce-in">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
||||
</svg>
|
||||
<span>Back to Home</span>
|
||||
</a>
|
||||
|
||||
<div class="max-w-7xl mx-auto p-6 relative">
|
||||
<!-- Header -->
|
||||
<div class="flex justify-between items-center mb-8">
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold mb-2 text-gray-800 dark:text-white">Manage Projects</h1>
|
||||
<p class="text-gray-600 dark:text-gray-400">Add, edit, and manage your portfolio projects</p>
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
<a href="add_project.php" class="btn-primary inline-flex items-center space-x-2">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
||||
</svg>
|
||||
<span>Add New Project</span>
|
||||
</a>
|
||||
<a href="?logout=1" class="bg-white dark:bg-dark-card text-gray-700 dark:text-gray-300 px-6 py-3 rounded-lg shadow-lg hover:shadow-xl font-medium transition-all duration-200 border border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path>
|
||||
</svg>
|
||||
Logout
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Messages -->
|
||||
<?= $message ?? '' ?>
|
||||
|
||||
<!-- Edit Form -->
|
||||
<?php if ($edit_project): ?>
|
||||
<div class="mb-8 bg-white dark:bg-dark-card p-8 rounded-2xl shadow-xl transition-colors duration-200 border border-gray-200 dark:border-gray-600">
|
||||
<h2 class="text-2xl font-semibold mb-6 text-gray-800 dark:text-white flex items-center">
|
||||
<svg class="w-6 h-6 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
|
||||
</svg>
|
||||
Edit Project
|
||||
</h2>
|
||||
<form method="post" enctype="multipart/form-data" class="space-y-6">
|
||||
<input type="hidden" name="edit_id" value="<?= $edit_project['id'] ?>">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Title</label>
|
||||
<input type="text" name="title" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" value="<?= htmlspecialchars($edit_project['title']) ?>" required>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Project URL</label>
|
||||
<input type="text" name="project_url" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" value="<?= htmlspecialchars($edit_project['project_url']) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Short Description</label>
|
||||
<textarea name="description" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" rows="2"><?= htmlspecialchars($edit_project['description']) ?></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Long Description</label>
|
||||
<textarea name="long_description" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" rows="4"><?= htmlspecialchars($edit_project['long_description'] ?? '') ?></textarea>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Current Image</label>
|
||||
<?php if ($edit_project['image_url']): ?>
|
||||
<img src="../<?= htmlspecialchars($edit_project['image_url']) ?>" alt="" class="h-32 w-32 object-cover rounded-lg mb-2 border border-gray-200 dark:border-gray-600">
|
||||
<?php else: ?>
|
||||
<div class="h-32 w-32 bg-gray-100 dark:bg-gray-700 rounded-lg flex items-center justify-center border border-gray-200 dark:border-gray-600">
|
||||
<span class="text-gray-500 dark:text-gray-400 text-sm">No image</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Upload New Image</label>
|
||||
<input type="file" name="image_file" accept="image/*" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Or Image URL</label>
|
||||
<input type="text" name="image_url" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" value="<?= htmlspecialchars($edit_project['image_url']) ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Tags</label>
|
||||
<input type="text" name="tags" class="w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors" value="<?= htmlspecialchars($edit_project['tags']) ?>">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2">Separate tags with commas</p>
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
<button type="submit" class="btn-primary px-6 py-3">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
||||
</svg>
|
||||
Save Changes
|
||||
</button>
|
||||
<a href="index.php" class="text-gray-600 dark:text-gray-400 hover:underline font-medium px-6 py-3 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Projects Grid -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<?php foreach ($projects as $project): ?>
|
||||
<div class="project-card p-6 transition-all duration-200 hover-lift">
|
||||
<?php if ($project['image_url']): ?>
|
||||
<img src="../<?= htmlspecialchars($project['image_url']) ?>" alt="" class="project-image h-48 w-full object-cover rounded-lg mb-4">
|
||||
<?php endif; ?>
|
||||
<h3 class="text-xl font-semibold mb-2 text-gray-800 dark:text-white"><?= htmlspecialchars($project['title']) ?></h3>
|
||||
<p class="text-gray-700 dark:text-gray-300 mb-4 line-clamp-2"><?= htmlspecialchars($project['description']) ?></p>
|
||||
<?php if ($project['tags']): ?>
|
||||
<div class="mb-4 flex flex-wrap gap-2">
|
||||
<?php foreach (explode(',', $project['tags']) as $tag): ?>
|
||||
<span class="tag text-xs"><?= htmlspecialchars(trim($tag)) ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="flex justify-between items-center">
|
||||
<?php if ($project['project_url']): ?>
|
||||
<a href="<?= htmlspecialchars($project['project_url']) ?>" target="_blank" class="text-blue-600 dark:text-blue-400 hover:underline text-sm font-medium">View Project →</a>
|
||||
<?php endif; ?>
|
||||
<div class="flex gap-3">
|
||||
<a href="?edit=<?= $project['id'] ?>" class="bg-blue-600 dark:bg-blue-700 text-white px-4 py-2 rounded-lg hover:bg-blue-700 dark:hover:bg-blue-800 transition-colors text-sm font-medium">Edit</a>
|
||||
<a href="?delete=<?= $project['id'] ?>" class="bg-red-600 dark:bg-red-700 text-white px-4 py-2 rounded-lg hover:bg-red-700 dark:hover:bg-red-800 transition-colors text-sm font-medium" onclick="return confirm('Delete this project?');">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="../js/dark-mode.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
129
projects/challenge 11/portifolio(work_in_progress)/db/login.php
Normal file
129
projects/challenge 11/portifolio(work_in_progress)/db/login.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Change these credentials as needed
|
||||
$USERNAME = 'admin';
|
||||
$PASSWORD = 'password123';
|
||||
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$user = $_POST['username'] ?? '';
|
||||
$pass = $_POST['password'] ?? '';
|
||||
if ($user === $USERNAME && $pass === $PASSWORD) {
|
||||
$_SESSION['logged_in'] = true;
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid username or password.';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - Manage Projects</title>
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Tailwind CSS CDN -->
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
dark: {
|
||||
bg: '#0f172a',
|
||||
card: '#334155',
|
||||
text: '#f1f5f9'
|
||||
}
|
||||
},
|
||||
fontFamily: {
|
||||
'sans': ['Inter', 'system-ui', 'sans-serif'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="../css/styles.css">
|
||||
<link rel="stylesheet" href="../css/animations.css">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/svg+xml" href="../assets/favicon.svg">
|
||||
</head>
|
||||
<body class="min-h-screen flex items-center justify-center transition-colors duration-200">
|
||||
<!-- Back to home button -->
|
||||
<a href="../index.php" class="fixed top-6 left-6 btn-primary inline-flex items-center space-x-2 z-50 animate-bounce-in">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
||||
</svg>
|
||||
<span>Back to Home</span>
|
||||
</a>
|
||||
|
||||
<!-- Login form container -->
|
||||
<div class="bg-white dark:bg-dark-card p-8 rounded-2xl shadow-xl w-full max-w-md mx-4 transition-colors duration-200 border border-gray-200 dark:border-gray-600">
|
||||
<div class="text-center mb-8">
|
||||
<h1 class="text-3xl font-bold mb-2 text-gray-800 dark:text-white">Sign In</h1>
|
||||
<p class="text-gray-600 dark:text-gray-400">Access your project management dashboard</p>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="bg-red-100 dark:bg-red-900/50 text-red-800 dark:text-red-200 p-4 rounded-lg mb-6 border border-red-200 dark:border-red-800 animate-bounce-in">
|
||||
<div class="flex items-center space-x-2">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
<span><?= htmlspecialchars($error) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" class="space-y-6">
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Username</label>
|
||||
<div class="relative">
|
||||
<svg class="absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
|
||||
</svg>
|
||||
<input type="text" name="username"
|
||||
class="w-full pl-10 pr-4 py-3 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
||||
placeholder="Enter your username"
|
||||
required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block font-medium mb-3 text-gray-700 dark:text-gray-300">Password</label>
|
||||
<div class="relative">
|
||||
<svg class="absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"></path>
|
||||
</svg>
|
||||
<input type="password" name="password"
|
||||
class="w-full pl-10 pr-4 py-3 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
||||
placeholder="Enter your password"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-primary w-full py-3 text-lg font-semibold">
|
||||
<svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"></path>
|
||||
</svg>
|
||||
Sign In
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="../js/dark-mode.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user