Expert assistant for the SONGLY PHP lyrics website. Helps with database operations, admin panel features, CRUD operations, and frontend development following the project's established patterns.
An expert AI assistant for working with the SONGLY song lyrics website codebase. This skill helps you navigate, modify, and extend a PHP-based application with MySQL database backend.
This skill provides expert guidance for:
1. **singer** - Singer information (id, name, followers, contributions, description, image_path)
2. **songs** - Song catalog (id, name, singer_id, auditions, image_path)
3. **albums** - Album information (id, name, singer_id, release_year, image_path)
4. **textsong** - Song lyrics (song_id, producer, lyrics_text)
5. **admin_users** - Admin authentication (id, username, password_hash)
When working with this codebase, follow these guidelines:
**Always use prepared statements:**
```php
$stmt = $conn->prepare("SELECT * FROM singer WHERE id_singer = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
// ... process results
$stmt->close();
```
**For SELECT queries:**
**For INSERT/UPDATE queries:**
**Adding new CRUD pages:**
1. Copy the pattern from existing admin pages (e.g., `admin_songs.php`)
2. Include authentication check at the top: `require_once('auth_check.php');`
3. Follow the naming convention: `admin_{entity}.php`, `admin_{entity}_add.php`, `admin_{entity}_edit.php`, `admin_{entity}_delete.php`
4. Use Bootstrap 5.3.0 classes for consistent UI
5. Include the image upload handler if needed: `require_once('includes/upload_image.php');`
**Image uploads:**
```php
$upload_result = uploadImage($_FILES['image'], 'singer'); // or 'song', 'album'
if ($upload_result['success']) {
$image_path = $upload_result['path']; // Store this in database
}
```
**Dynamic content pages:**
**Common patterns:**
```php
// Get singer with top songs
$singer_id = intval($_GET['id']);
$stmt = $conn->prepare("SELECT * FROM singer WHERE id_singer = ?");
// ... execute and fetch singer
// Get top 4 songs
$stmt = $conn->prepare("SELECT * FROM songs WHERE id_singer = ? ORDER BY number_of_auditions DESC LIMIT 4");
```
**Authentication:**
**Input validation:**
**SQL injection prevention:**
**Local testing:**
```bash
php -S localhost:8000
```
**Admin panel access:**
**Database changes:**
**Adding a new entity type:**
1. Create database table with proper schema
2. Add CRUD admin pages following existing patterns
3. Create frontend display pages
4. Set up image directory if needed
5. Add navigation links in admin sidebar
**Modifying existing features:**
1. Read the relevant PHP file first
2. Identify database queries and data flow
3. Make changes while preserving prepared statement pattern
4. Test both success and error cases
5. Verify XSS protection on any new output
**Debugging:**
1. Check database connection in `config/db_config.php`
2. Verify table/column names match schema
3. Enable PHP error reporting during development
4. Check file permissions for image directories
5. Validate session handling for admin features
**User request:** "Help me add a new singer through the admin panel"
**Agent response:**
1. Navigate to `/admin/admin_singer_add.php`
2. Fill in the form fields (name, followers, contributions, description)
3. Upload singer image (JPG/PNG/GIF, max 5MB)
4. Submit form - the system will:
- Validate input data
- Upload image to `images/singer/` directory
- Insert record with image_path into `singer` table
- Redirect to singer list page
**User request:** "Show me how to get the top 10 most popular songs"
**Agent response:**
```php
$stmt = $conn->prepare("SELECT s.*, si.name_singer
FROM songs s
JOIN singer si ON s.id_singer = si.id_singer
ORDER BY s.number_of_auditions DESC
LIMIT 10");
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo htmlspecialchars($row['name_songs']) . " - ";
echo htmlspecialchars($row['name_singer']) . "<br>";
}
$stmt->close();
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/songly-php-project-helper/raw