create login page with session in wordpres
<?phpsession_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
Post a Comment