Skip to main content
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

Searching In Array-:



  • Searching means to find whether a particular value is present in the array or not.
  • If the value is present in array then the search is said to be successful and the search process gives the location of that value in array,otherwise,if the value is not present in the array the search process displays the appropriate message and in this case search is said to be unsuccessful.
  • There are two popular methods for searching the array elements-:
              1- Linear Search CLICK HERE
              2- Binary Search CLICK HERE
Watch The Videos Below


ads






<!DOCTYPE html>
<html>
<head>
    <title>User Login</title>
</head>
<body>
    <h1>User Login</h1>
    <form method="post" action="login_process.php">
        <label for="email">Email:</label>
        <input type="email" name="email" required>
        <br>
        <label for="password">Password:</label>
        <input type="password" name="password" required>
        <br>
        <button type="submit">Login</button>
    </form>
</body>
</html>






<?php
// Establish database connection (Replace the placeholders with your database credentials)
$servername = "your_servername";
$username = "your_username";
$password = "your_password";
$dbname = "your_database_name";

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

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Function to safely handle user inputs
function sanitize_input($input)
{
    return htmlspecialchars(trim($input));
}

// Handle login form submission
if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $email = sanitize_input($_POST["email"]);
    $password = $_POST["password"];

    // Retrieve the user record based on the provided email
    $sql = "SELECT id, password, is_admin FROM users WHERE email = '$email'";
    $result = $conn->query($sql);

    if ($result->num_rows === 1) {
        $row = $result->fetch_assoc();
        $hashed_password = $row["password"];
        $is_admin = $row["is_admin"];

        // Verify the provided password against the hashed password in the database
        if (password_verify($password, $hashed_password)) {
            echo "Login successful!";
            // Now you can set session variables or perform other actions based on the user's role (is_admin)
        } else {
            echo "Invalid email or password.";
        }
    } else {
        echo "Invalid email or password.";
    }
}

$conn->close();
?>

Comments

Post a Comment

Please do not enter any spam link in the comment box.


Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey