login form php code । html,css and php login form | পিএইসপি লগইন ফর্ম কোড

In a previous post, we have created a login form. Now, let's explore how to save the data submitted in the form. I'll provide you with detailed steps and code examples for each part of the process.

Step 1: Design the Login Form (login.html)

Create an HTML form that allows users to input their email and password:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1' name='viewport'/>
    <title>Login Form</title>
</head>
<body>
    <form method="post" action="login.php">
        <label for="name">Email:</label>
        <input type="text" name="name" required><br><br>
        <label for="password">Password:</label>
        <input type="password" name="password" required><br><br>
        <input type="submit" name="login" value="Login">
    </form>
</body>
</html>

Step 2: Process Form Data and Save (login.php)

Create a PHP script that processes the form data and saves it to a file named "password.txt":
<?php
if(isset($_POST['login'])){
    $Name = "Email: ".$_POST['name']."\n";
    $Pass = "Password: ".$_POST['password']."\n";

    $file = fopen("password.txt", "a");
    fwrite($file, $Name);
    fwrite($file, $Pass);
    fclose($file);

    header('location: submit.html');
}
?>

Step 3: Submission Confirmation (submit.html)

Design a confirmation page that the user will see after submitting the form:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1' name='viewport'/>
    <title>Successfully Account Created</title>
    <style>
        / Your CSS styles here /
    </style>
</head>
<body>
    <div class="f1">
        <font color="#FFFFFF">
            You Have Successfully Entered Your Username and Password
        </font>
    </div>
    <center>
        <br><br>
        <div class="f2">
            Now you can easily use your account.
        </div>
        <br>
        <footer>
            <a href="https://agileposts.blogspot.com/">
                <button>
                    Visit My Website
                </button>
            </a>
        </footer>
    </center>
</body>

Step 4: Explanation

- `login.html`: This file contains the HTML form design.
- `login.php`: The PHP script for processing the form data and saving it to "password.txt".
- `submit.html`: A confirmation page that users see after submitting the form.
- `password.txt`: This file stores the saved email and password data.

Remember, all these files should be saved in the same folder. You can use a web server like XAMPP for testing the PHP code or a mobile app like Penguin for Android development and testing.

Feel free to ask if you need further assistance or have any questions!
Next Post Previous Post
No Comment
Add Comment
comment url