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 :: Update Query in Codeigniter Using Multiple Where Condition 
Php :: how to fetch all column values php 
Php :: set postman global variable header 
Php :: get from table laravel 
Php :: int to char php 
Php :: date in php 
Php :: passing parameters with route keyword in blade laravel 
Php :: laravel detach 
Php :: wordpress post types supports thumbnail 
Php :: doctrine orm get all 
Php :: laravel 5 use env variable in blade 
Php :: date time in php 
Php :: get_the_category() 
Php :: php unlink 
Php :: php is int 
Php :: include php file from another folder 
Php :: file could not be downloaded: Unable to find the wrap per "https" - did you forget to enable it when you configured PHP? failed to open stream: No such file or directory 
Php :: php json decode not working on array 
Php :: laravel validation in controller 
Php :: guzzle http client 
Php :: concatener 2 variables php 
Php :: return json in middleware laravel 
Php :: post php 
Php :: laravel auth check login 
Php :: how to get yearly chart in laravel 
Php :: in_array validation laravel 
Php :: php function crop image 
Php :: is serialized php 
Php :: wp image size names 
Php :: laravel create model controller and migration on line 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =