Easy way to Create Admin login using Dreamweaver CS6

Easy way to Create Admin login using Dreamweaver CS6: Creating an admin login system in Dreamweaver CS6 involves several steps, including setting up a database, creating HTML forms, and writing server-side scripts (usually in PHP). Here’s a simplified guide to help you set up an admin login system:

Prerequisites

  1. DreamWeaver CS6 installed on your computer.
  2. A web server with PHP and MySQL (e.g., XAMPP, WAMP, or a live server).
  3. Basic knowledge of HTML, CSS, PHP, and MySQL.

Steps to Create Admin Login System

  1. Set Up the Database

First, create a database to store your admin login credentials.

  1. Open phpMyAdmin (or any MySQL management tool).
  2. Create a new database called admin_db.
  3. Create a new table called admin_users with the following fields:
    • id (INT, primary key, auto-increment)
    • username (VARCHAR)
    • password (VARCHAR)

 

 

CREATE TABLE admin_users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(50) NOT NULL,

password VARCHAR(255) NOT NULL

);

 

  1. Insert an admin user into the table (ensure the password is hashed):

INSERT INTO admin_users (username, password) VALUES (‘admin’, ‘hashed_password’);

(Use PHP’s password_hash function to generate a hashed password).

  1. Create the Login Form

Create an HTML form for the admin login.

  1. Open DreamWeaver CS6.
  2. Create a new file (File -> New) and select HTML.
  3. Design the login form in the Design view or Code view.

 

<!DOCTYPE html>

<html lang=”en”>

 <head>

<meta charset=”UTF-8″>

<title>Admin Login</title>

</head>

<body>

<h2>Admin Login</h2>

<form action=”login.php” method=”post”>

 <label for=”username”>Username:</label>

<input type=”text” id=”username” name=”username” required> <br>

<label for=”password”>Password:</label>

 <input type=”password” id=”password” name=”password” required> <br>

 <input type=”submit” value=”Login”>

</form>

</body>

</html>

 

  1. Create the Login Script

Create a PHP script to handle the form submission and authenticate the user.

  1. Create a new PHP file (File -> New) and select PHP.
  2. Save the file as php.

 

<?php

session_start();

$servername = “localhost”;

$username = “root”; // your database username

$password = “”; // your database password

$dbname = “admin_db”; // Create connection

$conn = new mysqli($servername, $username, $password, $dbname); // Check connection

if ($conn->connect_error) { die(“Connection failed: ” . $conn->connect_error); }

if ($_SERVER[“REQUEST_METHOD”] == “POST”) { $user = $_POST[‘username’];

$pass = $_POST[‘password’]; // Prepare and bind

$stmt = $conn->prepare(“SELECT id, password FROM admin_users WHERE username = ?”);

$stmt->bind_param(“s”, $user);

$stmt->execute(); $stmt->bind_result($id, $hashed_password); $stmt->fetch();

if (password_verify($pass, $hashed_password)) { $_SESSION[‘admin_logged_in’] = true; header(“Location: admin_dashboard.php”);

} else {

echo “Invalid username or password.”;

} $stmt->close();

} $conn->close();

?>

  1. Create the Admin Dashboard

Create a simple admin dashboard that only logged-in users can access.

  1. Create a new PHP file and save it as php.

 

<?php session_start();

if (!isset($_SESSION[‘admin_logged_in’])) {

header(“Location: index.html”); // redirect to login if not logged in exit();

}

?>

 

<!DOCTYPE html> <html lang=”en”>

<head>

<meta charset=”UTF-8″>

<title>Admin Dashboard</title>

</head>

<body>

<h2>Welcome to Admin Dashboard</h2>

<p>Only accessible by logged-in admin users.</p>

</body>

</html>

 

Testing your application

  1. Run your local server (e.g., XAMPP, WAMP).
  2. Open your web browser and navigate to the login form (e.g., http://localhost/yourproject/index.html).
  3. Enter your admin credentials and click login to test if you can access the admin dashboard.

This is a basic guide to create an admin login system using DreamWeaver CS6, HTML, and PHP. For enhanced security and features, consider implementing additional measures such as prepared statements, password hashing with password_hash, and using HTTPS.

Previous articleBeginner: Are you stuck in programming should not do
Next articleEasy way of using Adobe Dreamweaver CS6

LEAVE A REPLY

Please enter your comment!
Please enter your name here