Skip to main content

How to create login page with session in wordpress.

create login page with session in wordpres
<?php
session_start();
if (isset($_SESSION['ID']))
{
echo '<script LANGUAGE="JavaScript">window.location.href="'.site_url().'/login-dashboard";</script>';
}


<?php
if(isset($_POST['submit']))
{

$email=$_POST['email'];
$password=$_POST['password'];
       
        global $wpdb;
        $result = $wpdb->get_results ( "SELECT * FROM `wp_apindt_employee` WHERE email='$email' and password='$password'" );
        foreach ( $result as $print ) 
        {
           $ID=$print->ID ;



    }


           

$count = count($result);
if($count > 0)
{
session_start();
$_SESSION['ID']=$ID;
   echo '<script LANGUAGE="JavaScript">window.location.href="'.site_url().'/login-dashboard";</script>';
}
else
{
echo '<script LANGUAGE="JavaScript">window.location.href="'.site_url().'/login-form/";</script>';
}
  }
?>


<html>
<style>


</style>
<body>
<div class="wrap">
<form action="" method="post">
<div><label>Email</label><input type="text" name="email" placeholder="Email"></div>
<div><label>Password</label><input type="text" name="password" placeholder="password"></div>
<div><input type="submit" name="submit" value="submit"></div>

</form>
</div>
</body>
</html>



Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...