Skip to content
This is my space, where experience meets the will to start over. This is my space, where experience meets the will to start over.

The first step is knowing where you want to go.

  • Home
  • Coding Hub
    • Software & Project
      • Small Biz Ops – S.B.O.
        • SmallBizOps – Day 10/90
      • CRM/ERP
      • MyTracker
      • My Budget
    • Form Zero to “WoW”
      • JavaScript from Zero (Completed)
        • 2. Remove and Edit List Items
        • 3. Separate HTML and JavaScript, Use addEventListener and Conditional Logic
        • 4. Add Dynamic CSS Classes
        • 5. Save & Restore Your List with localStorage
        • 6 – Turn Your App into a Full To-Do List
      • Python from Zero (Completed)
        • 2. Lists & Loops
        • 3. Conditional Menus
        • 4. Edit & Remove Tasks (with closing: Python vs PHP and Large Data)
        • 5 – Save to File: Make Your Tasks Survive Restarts
        • 6 β€” Pythin from zero – Final Project Polishing: Numbering, Formatting, and Preparing for CSV
      • Rust – From Zero to β€œWoW” (Completed)
        • 1 – Setup and Project Structure in Rust
        • 2 – User input: validation and error handling
        • 3 – Rust from Zero to β€œWoW – BMI Calculation and Conditional Logic
        • 4 –Rust – Clear, Formatted Output
        • 5 – Rust – Final Thoughts: Precision as a Form of Respect
      • Go from Zero to β€œWoW” (Completed)
        • 1 – Why Go Is Perfect for a Personal Expense Tracker
        • 2 – Logging Expenses and Console Input
        • 3 – Go from Zero to β€œWoW” – Smart Filtering & Display Logic
        • 4 – Go – Saving Data to Local Files
        • 5 – Go – Final Project – Expense Tracker in Go
      • C++ from Zero to β€œWoW” (Completed)
        • 1 – Why C++ for file organization?
        • 2 – C++ – File Type Detection and Classification
        • 3 – C++ – Creating & Managing Subfolders
        • 4 – C++ – Safe File Movement and User Feedback
        • 5 – C++ – Order as Mental Clarity
      • Ubuntu – From Zero to β€œWoW” (Completed)
        • 2 – Ubuntu – The Desktop Environment and Essential Commands
        • 3 – Ubuntu – Managing Files, Folders, and Permissions
        • 4 – Ubuntu – Installing and Updating Software with APT and Snap
        • 5 – Ubuntu – Customizing the Desktop Environment
        • 6 – Ubuntu – Network and Device Configuration
        • 7 – Ubuntu – User Management & System Security β€” β€œThe Cathedral of Permissions”
        • 8 – Ubuntu – The Talking Machine: Terminal & Bash Scripting
        • 9 – Ubuntu – Ubuntu as a Server or Development Environment
        • 10 – Ubuntu – Backup, Maintenance & Troubleshooting
    • Git Hub Repository
      • Small Biz Ops – S.B.O.
      • Mini ERP – PHP & MySQL
      • CleverCRM (Java, Spring Boot)
      • FraudWatch (Python, FastAPI + scikit-learn)
      • OnboardIQ – Smart Onboarding Portal (Flask + SQLite Demo)
    • ArchPilot
      • 1-Users & Roles, End-to-End (Architecture, Database, and Cross-Framework Code)
      • 2 – Client Registry (CRM) Across Frameworks
      • 3 – Project & Budget Tracker (ERP)
      • 4 – Approval Workflow Engine Multi-step routing, status tracking, escalation paths
      • 5 – Audit Trail & Versioning
    • Small Biz Ops – S.B.O.
  • Vivere in USA
  • P4Y
  • Testi poetici
    • 1 – Sospeso
    • 2 – Il bicchiere di vetro quieto
    • 3 – Quando l’amore inciampa
    • 4 – Ma chi siete davvero?
    • 5 – Above the Thread of Day
    • 6 – The Truth That Doesn’t Exist
    • 7 – All of You, I Miss
    • 8 – The Captain and the Ocean
    • 9 – Between Light and Mist
    • 10 – Il peso delle scelte
  • Contact
  • Admin
This is my space, where experience meets the will to start over.
This is my space, where experience meets the will to start over.

The first step is knowing where you want to go.

Coding – Step 3 – πŸ” Secure Access Project – Comparing Languages and Security

Posted on 6 Giugno 202526 Luglio 2025 By Francesco

This section provides a practical example of how the same login functionality can be implemented using three different technologies. Each version is based on the same user database (username and hashed password), but the logic, structure, and experience vary significantly depending on the approach.


πŸ’‘ The Goal

To compare how secure login systems work when written in:

  • pure PHP
  • API-based architecture
  • JavaScript-based asynchronous logic

Each method has pros and cons, both for the user and the site developer.


🧩 The 3 Secure Access Versions

πŸ”Έ 1. Secure PHP Login

  • Language: Pure PHP
  • Behavior: The login form posts directly to a PHP script. If login is valid, user is redirected to a success page; otherwise to an error page.
  • User experience: Traditional (page reload)
  • Management: Easy to deploy, no frontend frameworks required

Main code snippet:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $stmt = $pdo->prepare("SELECT password FROM users WHERE username = ?");
    $stmt->execute([$username]);
    $user = $stmt->fetch();

    if ($user && password_verify($password, $user['password'])) {
        header("Location: welcome.php");
    } else {
        header("Location: error.php");
    }
}

βœ… Pros: Minimalistic and functional
❌ Cons: Less interactive; not ideal for modern UIs


πŸ”Έ 2. Secure API-Based Login

  • Language: PHP + JSON API
  • Behavior: The login form sends credentials to an API endpoint. The server responds with a JSON message (success or error). The page updates accordingly without reload.
  • User experience: Fast and dynamic
  • Management: Scalable and modular; allows decoupling frontend and backend

API backend logic (PHP):

$data = json_decode(file_get_contents("php://input"), true);
$username = $data['username'] ?? '';
$password = $data['password'] ?? '';

$stmt = $pdo->prepare("SELECT password FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();

echo json_encode([
  "status" => $user && password_verify($password, $user['password']) ? "success" : "error"
]);

βœ… Pros: Clean separation of responsibilities
❌ Cons: Requires frontend logic and good error handling


πŸ”Έ 3. Secure JavaScript Login

  • Language: HTML + JavaScript (AJAX) + PHP backend
  • Behavior: The JS handles form submission using fetch() and updates the page dynamically.
  • User experience: Instant and modern
  • Management: Needs secure backend and client-side validation

JavaScript logic:

document.getElementById("loginForm").addEventListener("submit", async function(e) {
  e.preventDefault();
  const form = new FormData(this);
  const res = await fetch("check.php", { method: "POST", body: form });
  const result = await res.json();

  if (result.status === "success") {
    window.location.href = "welcome.html";
  } else {
    document.getElementById("errorMsg").innerText = "Invalid login";
  }
});

βœ… Pros: Great user experience
❌ Cons: Needs CSRF and session protection


πŸ“Š Summary Table

FeaturePHP VersionAPI VersionJS Version
Page reloadYesNoNo
User experienceClassicSmoothInstant
Frontend complexityLowMediumHigh
ModularityLowHighMedium
Developer controlFullSharedShared
CSRF protection neededNo (if POST)YesYes

🧠 Why This Matters

Even a simple login form should never rely on insecure practices like storing plain-text passwords. That’s why in all three methods, I implemented:

  • βœ… password_hash() and password_verify()
  • βœ… SQL injection protection using prepare()
  • βœ… Session management
  • βœ… Optional CSRF tokens

🏁 Final Thoughts

This project is an educational showcase that compares three different paths to building the same functionality. They highlight:

  • how technology influences user experience,
  • what each approach demands from the developer,
  • and how to think about security early in any project.

The code is available, the demos are online, and this can serve both as a study reference and a demonstration of programming style and evolution.


Post Views: 386

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Coding

Navigazione articoli

Previous post
Next post

Francesco

My name is Francesco Boschi, originally from Italy and currently based in the United States. For over twenty years, I’ve worked as a manager and consultant across diverse sectors β€” from education and cultural institutions to the food industry β€” developing skills in operational management, strategic consulting, and complex problem-solving. In recent years, I’ve combined this experience with a strong passion for software development, creating custom tools designed to simplify workflows and meet real business needs.

Relocating to the U.S. marks the beginning of a new chapter: a personal and professional decision driven by the desire to be close to my son and to embrace new challenges in a different environment. Today, my goal is to turn my experience into meaningful solutions, blending strategic vision with technical expertise to help people and organizations work more effectively.

I enjoy moving between different worlds, adapting tools and approaches to people and contexts. I bring leadership, flexibility, attention to detail, analytical thinking, and a strong problem-solving mindset β€” along with a deep curiosity to learn and grow. Above all, I believe in sharing: I’m always eager to offer my experience to support the growth of others.

Related Posts

Coding

Coding – Step 4 -Behind the Scenes of a Well-Built Customer Registration System

Posted on 8 Giugno 202526 Luglio 2025

A project that may seem simple, but is driven by purpose, philosophy, and technical precision. Introduction In today’s digital landscape, software interfaces are often judged at first glance. A registration form, for instance, might appear to be a trivial pageβ€”a set of fields and a submit button. But behind that…

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More
Coding

ArchPilot – Step 4 – Approval Workflow Engine Multi-step routing, status tracking, escalation paths

Posted on 6 Dicembre 20256 Dicembre 2025

Step 4 of ArchPilot explores a simple, multi-step Approval Workflow Engine and compares how different frameworks handle the same approval logic in real ERP/CRM scenarios.

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More
Coding

Coding – Step 13.3 – C++ from Zero to “WoW” – Creating & Managing Subfolders

Posted on 7 Ottobre 20257 Ottobre 2025

Build a cross‑platform C++17/20 utility to create, verify, list, and remove nested folders using , with robust error handling, dry‑run mode, and idempotent operations.

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More

Iscriviti alla nostra Newsletter

🀞 Let's keep in touch

We do not send spam! Read ourΒ Privacy policyΒ for more information.

Controlla la tua casella di posta o la cartella spam per confermare la tua iscrizione

Cerca nel sito

©2026 This is my space, where experience meets the will to start over. | WordPress Theme by SuperbThemes