Search
 
SCRIPT & CODE EXAMPLE
 

PHP

using PDO and PHP => Login.php

function check($data)
{
    $email = $data['email'];
    $password = $data['password'];
    $sql = "SELECT * FROM users WHERE email = ? password = ?";
    $params = [$email, $password];
    $result = $this->doSelect($sql, $params);
    print_r($result);
    //if (sizeof($result) > 0) {
    //     echo 'yes';
    //} else {
    //    echo 'no';
    //}
}
Comment

login form using php pdo

include './database/PDO.php';

$sendmessage = null;
$Message = null;

if (isset($_POST['enter'])){
    $email = $_POST['email'];
    $password = $_POST['password'];
    $result = $conn-> prepare("SELECT * FROM sign WHERE email=? AND password=?");
    $result->bindValue(1, $email);
    $result->bindValue(2, $password);
    $result->execute();
    header('location: ./dashboard.php');
    $sendmessage = true;

    if($result->rowCount()>=1){
        $rows = $result->fetch(PDO::FETCH_ASSOC);
        $_SESSION['login']= true;
        $_SESSION['email']= $email;
        $_SESSION['password']= $password;
        $_SESSION['role']= $rows['role'];
        if(isset($_POST['rem'])){
            setcookie('email', $SESSION['email'], time()+60*60*24*7, '/');
            setcookie('password', $SESSION['password'], time()+60*60*24*7, '/');

        }else{
            echo $Message= true;
        }

    }else{
        echo $Message= true;
    }
}
?>
  <form class="row g-3 needs-validation" method="POST" novalidate>
                <label for="validationCustom02" class="form-label">ایمیل</label>
                <input type="email" name="email" class="form-control" id="validationCustom02"
                       required>
                <div class="invalid-feedback">
                    <div class="alert alert-danger" role="alert">
                        لطفا فیلد ایمیل را پر کنید

                    </div>
                </div>

                <label for="validationCustom02" class="form-label">نام کاربری شما</label>
                <input type="text" name="username" class="form-control" id="validationCustom02"
                       required>
                <div class="invalid-feedback">
                    <div class="alert alert-danger" role="alert">
                        لطفا فیلد نام کاربری را پر کنید

                    </div>
                </div>
                <label for="validationCustom02" class="form-label">رمز عبور </label>
                <input type="password" class="form-control" id="validationCustom02" name="password" required>
                <div class="invalid-feedback">
                    <div class="alert alert-danger" role="alert">
                        لطفا فیلد پسورد را پر کنید

                    </div>
                </div>
                <input type="checkbox" name="rem" class="form-check-input mt-3">
                <label class="form-label" style="margin-right: 50px;margin-top: -20px;">مرا به خاطر بسپار</label>
                <input type="submit" value="ورود" class="btn btn-primary" name="enter">

            </form>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel collection times 
Php :: phpexcel set row height 
Php :: Add Text Before the Product Title 
Php :: faker image laravel 8 
Php :: laravel outer join 
Php :: laravel search multiple (related) tables 
Php :: javascript function in php json_encode 
Php :: laravel get view variables 
Php :: laravel Auth::logoutOtherDevices 
Php :: Set a minimum subtotal amount in Woocommerce cart 
Php :: laravel blade components 
Php :: laravel collection sum 
Php :: php try json decode and check 
Php :: create table laravel 
Php :: update query laravel 
Php :: php pdo setting error modes 
Php :: wordpress change post format 
Php :: get all users created in a month laravel 
Php :: laravel post request page csrf disable 
Php :: How to display custom field in wordpress? 
Php :: how to use custome functions in laravel 
Php :: wordpress add button to admin bar 
Php :: check current user role 
Php :: parse json phph 
Php :: Gravity Form Shortcode Wordpress 
Php :: Hide Add to cart button on specific products 
Php :: array_chunk in php 
Php :: php docs comments 
Php :: php localhost 
Php :: How to show total count in tables using php 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =