Full Stack Web Development Complete Guide
Full Stack Web Development Complete Guide
Full Stack Web Development Complete Guide
This book provides a detailed guide on how to create a fully functional e-commerce website using
front-end technologies
(HTML, CSS, JavaScript) and back-end frameworks (PHP and Node.js), while managing the entire
4. Back-end development with PHP and Node.js for handling dynamic functionalities.
cPanel is a user-friendly web hosting control panel that helps you manage your hosting account via
a web-based interface.
In this chapter, we'll walk through setting up and using cPanel for managing databases and web
server configurations.
You'll learn:
3. Create a new database by entering the database name and clicking "Create Database."
HTML (HyperText Markup Language) is the foundation of any web page. We'll start by setting up the
structure of an e-commerce
website using HTML. Here's a simple outline of how an e-commerce site's homepage might be
structured.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<header>
<nav>
<a href="index.html">Home</a>
<a href="products.html">Products</a>
<a href="cart.html">Cart</a>
<a href="login.html">Login</a>
</nav>
</header>
<main>
<section id="featured-products">
<h2>Featured Products</h2>
</section>
</main>
<footer>
</footer>
</body>
</html>
```
CSS (Cascading Style Sheets) is used to style the HTML structure. Here is how you can add styling
to the homepage.
```css
body {
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #333;
color: white;
padding: 10px 0;
text-align: center;
nav a {
color: white;
margin: 0 15px;
text-decoration: none;
main {
padding: 20px;
background-color: white;
footer {
text-align: center;
padding: 10px 0;
background-color: #333;
color: white;
position: fixed;
width: 100%;
bottom: 0;
}
```
JavaScript will allow us to make the website interactive, handling actions like adding products to the
cart.
```javascript
function addToCart(productId) {
cart.push(productId);
```
This structure forms the basic front-end for your e-commerce website.
Chapter 3: Back-End Development
The back-end of an e-commerce website is what handles dynamic content, such as user data,
we'll explore how to use both PHP and Node.js to create server-side scripts.
PHP is widely used in web development for server-side scripting. Let's connect to the MySQL
```php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ecommerce";
// Create connection
// Check connection
if ($conn->connect_error) {
}
$sql = "SELECT id, name, price FROM products";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Price: " . $row["price"]. "<br>";
} else {
$conn->close();
?>
```
Node.js allows for the creation of fast, scalable network applications using JavaScript. Below is a
```javascript
const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'ecommerce'
});
db.connect(err => {
if (err) {
throw err;
console.log('MySQL Connected...');
});
res.send(results);
});
});
app.listen(3000, () => {
});
```
This will set up a Node.js server and a simple API endpoint for retrieving product data.
Chapter 4: Placeholder Content