Practical Exercises

Hands-on projects to practice your new skills

Table of Contents

Practical Projects and Exercises

This document contains hands-on projects and exercises designed to help VBScript/Classic ASP developers practice Python and PHP web development. Each project builds on the concepts learned in the training materials.

Exercise Structure

Each exercise includes:

  • Objective: What you'll learn
  • VBScript Reference: Similar Classic ASP functionality
  • Requirements: What the solution should do
  • Starter Code: Basic structure to get you started
  • Solution: Complete working implementation
  • Extensions: Additional features to implement

Beginner Exercises

Exercise 1: Personal Information Form (Python)

Beginner

Objective: Learn basic form handling and validation in Flask

VBScript Reference

<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim name, email, age
    name = Request.Form("name")
    email = Request.Form("email")
    age = Request.Form("age")
    ' Process form...
End If
%>

Requirements

  1. Create a form that collects name, email, and age
  2. Validate that all fields are filled
  3. Validate that email contains @ symbol
  4. Validate that age is a number between 18 and 100
  5. Display success message or errors
  6. Show submitted data in a table

Starter Code

Save as personal_info_app.py:

from flask import Flask, render_template, request, flash, redirect, url_for

app = Flask(__name__)
app.secret_key = 'your-secret-key'

# Store submissions in memory (in real app, use database)
submissions = []

@app.route('/', methods=['GET', 'POST'])
def personal_info():
    if request.method == 'POST':
        # TODO: Get form data
        # TODO: Validate data
        # TODO: Store valid data
        # TODO: Show success/error messages
        pass
    
    return render_template('personal_info.html', submissions=submissions)

if __name__ == '__main__':
    app.run(debug=True)

Exercise 2: Personal Information Form (PHP)

Beginner

Objective: Learn basic form handling and validation in PHP

Requirements: Same as Exercise 1, but implemented in PHP

Starter Code

Save as personal_info.php:

<?php
session_start();

// Store submissions in session (in real app, use database)
if (!isset($_SESSION['submissions'])) {
    $_SESSION['submissions'] = [];
}

$errors = [];
$success = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // TODO: Get form data
    // TODO: Validate data
    // TODO: Store valid data
    // TODO: Set success/error messages
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>Personal Information Form</title>
    <!-- Add CSS styling -->
</head>
<body>
    <h1>Personal Information Form</h1>
    
    <!-- TODO: Display success/error messages -->
    
    <form method="POST">
        <!-- TODO: Add form fields -->
        <input type="submit" value="Submit">
    </form>
    
    <!-- TODO: Display submissions table -->
</body>
</html>

Intermediate Exercises

Exercise 3: Simple Blog System (Python)

Intermediate

Objective: Learn CRUD operations, sessions, and file handling

VBScript Reference: Classic ASP blog with file storage or database

Requirements

  1. User can create blog posts (title, content, author)
  2. Display all posts on home page
  3. View individual post details
  4. Edit existing posts
  5. Delete posts
  6. Simple authentication (admin/password)
  7. Store posts in JSON file

Starter Code Structure

blog_app/
├── app.py
├── posts.json
└── templates/
    ├── base.html
    ├── home.html
    ├── post.html
    ├── edit.html
    └── login.html

Exercise 4: Simple Blog System (PHP)

Intermediate

Objective: Same as Exercise 3, but implemented in PHP

Requirements: Same as Exercise 3

Starter Code Structure

blog_php/
├── index.php
├── includes/
│   ├── functions.php
│   └── auth.php
├── data/
│   └── posts.json
└── pages/
    ├── home.php
    ├── post.php
    ├── edit.php
    └── login.php

Advanced Exercises

Exercise 5: Contact Management System (Python)

Advanced

Objective: Build a complete CRUD application with search and pagination

VBScript Reference: Classic ASP contact management with database

Requirements

  1. Add/edit/delete contacts (name, email, phone, company)
  2. Search contacts by name or company
  3. Pagination (10 contacts per page)
  4. Export contacts to CSV
  5. Import contacts from CSV
  6. User authentication with roles (admin/user)
  7. Use SQLite database

Exercise 6: Contact Management System (PHP)

Advanced

Objective: Same as Exercise 5, but implemented in PHP

Requirements: Same as Exercise 5

Exercise 7: E-commerce Product Catalog (Python)

Advanced

Objective: Build a complex web application with multiple features

Requirements

  1. Product catalog with categories
  2. Product search and filtering
  3. Shopping cart functionality
  4. User registration and login
  5. Order management
  6. Admin panel for product management
  7. Image upload for products
  8. Email notifications

Exercise 8: E-commerce Product Catalog (PHP)

Advanced

Objective: Same as Exercise 7, but implemented in PHP

Requirements: Same as Exercise 7

Challenge Projects

Challenge 1: API Development

Challenge

Objective: Learn to create REST APIs

Requirements

  1. Create a REST API for a task management system
  2. Endpoints: GET, POST, PUT, DELETE for tasks
  3. JSON request/response format
  4. Authentication with API keys
  5. Rate limiting
  6. Error handling
  7. API documentation

Implement in both Python (Flask) and PHP

Challenge 2: Real-time Chat Application

Challenge

Objective: Learn WebSocket programming and real-time features

Requirements

  1. Real-time chat interface
  2. Multiple chat rooms
  3. User authentication
  4. Message history
  5. Online user list
  6. File sharing
  7. Responsive design

Implement in both Python (Flask-SocketIO) and PHP (ReactPHP)

Getting Started

To begin working on these exercises:

  1. Start with Exercise 1: Begin with the personal information form to get comfortable with basic concepts
  2. Follow the progression: Each exercise builds on the previous ones
  3. Compare languages: Try implementing the same exercise in both Python and PHP
  4. Extend the exercises: Add your own features and improvements
  5. Use the training materials: Refer back to the Python and PHP training guides when needed

Tips for Success

  • Start small: Get the basic functionality working before adding advanced features
  • Test frequently: Run your code often to catch errors early
  • Use version control: Save your progress with Git
  • Read error messages: They often tell you exactly what's wrong
  • Compare with Classic ASP: Think about how you would solve the same problem in VBScript
  • Don't be afraid to experiment: Try different approaches and see what works

Next Steps

After completing these exercises, you'll have solid experience with both Python and PHP web development. Consider these next steps:

  • Learn frameworks: Explore Django (Python) or Laravel (PHP)
  • Build your own projects: Create applications that solve real problems
  • Deploy your applications: Learn about hosting and deployment
  • Contribute to open source: Join the community and contribute to projects
  • Keep learning: Web development is always evolving

Remember, the goal is not just to complete the exercises, but to understand the concepts and be able to apply them to your own projects. Take your time, experiment, and most importantly, have fun learning!