Search This Blog

07 March 2018

PHP Using Login Page

PHP USING LOGIN PAGE

1 1)   Signup the User Profile

   2)   Next to Login the your username and password put it Textbox 



<html>
<head></head>
// if you want any addition style sheet or online link add this 
<title> login page using php and sign up page </title>
<style>
.col1{
          position:relative;
          width:100%;
          height:100%;
       background-color:white;
      color: black;
}

.col2{
position: absolute;
    width: 40%;
    height: 55%;
    background-color: #F2F2F2;
    margin-left: 28%;
    margin-top: 8%; 
         
}
.inpt{
  padding: 12px;
   width:55%;
    border-radius: 4px;
    margin-left: 24%;
    border: 1px solid gray;
    padding-top:1px;
    marigin-top:1px;
   margin-left:1px;
margin-right:2px;
         
}
.btn{
    margin-left: 40%;
    border-radius: 4px;
    border: none;
    width: 16%;
    height: 10%;
    color:white;
    background-color: #6C7DD0;
}
</style>
<body> // body of the div
<div class="col1">
          <div class="col2">
          <br>
          <br>
          <br>  // form element starting this block
                   <form method="post" action="" enctype="multipart/form-data">
         <input type="text"  name=" uname " placeholder=" Enter Your username " class=" inpt "><br>
               <br>
                    <input type=" password "  name=" pwd " id=" pwd " placeholder=" Enter Your Password " class=" inpt "><br>
               <br>
                    <input type=" submit " onclick=' check(); ' value="login" name=" sub " class=" btn ">
                   </form>
          </div>
</div>
</body>
</html>
<?php
session_start(); // session starting 
// connect to the database
$con=mysqli_connect("localhost","root","","test"); 
// check the submit button is clicked or not 
if(isset($_POST['sub'])){
// get the post values using $_POST[''] method
$uname=$_POST['uname'];
$pwd=$_POST['pwd'];
$_SESSION['uname']=$uname;
$_SESSION['time']=time()+(30*60);
$sql=" select * from login where uname='$uname' and pwd='$pwd' ";
$res=$con->query($sql);
//counr the number of rows in the table
$cnt=mysqli_num_rows($res);
// check if  the record is no or yes
if($cnt==1){
echo "<script>alert('login sucessfully');window.location.href='logsuccess.php';</script>";
}else{
echo " <script> alert (' Your username or Password is wrong '); </script>";    
}
}
else{
echo " the user is not click the the submit button ";

}
?>

After Login:

<?php

// session start in this block
session_start();
// connect to the database 
$con=mysqli_connect("localhost","root","","test");
// print the logged user and get the session variable
echo "WELCOME MR".$_SESSION['uname']."<br>";
// the user is inactivity or something else automatically logout the session  
$now=time();
if($now > $_SESSION['time']){
          echo "<script> window.location.href=' loginpage.php '; </script> ";
          session_destroy();
}else{
   echo " user is active or working fine " ;
          //your statements;
}

Output:








03 March 2018

PHP using Dynamic Pagination

PHP USING DYNAMIC  PAGINATION


What is pagination?

Pagination is Easy to Navigate one page to another page and you want navigate specify page to select

<html>
<head></head>
<style>
.para {
 letter-spacing: 1px;
      font-size: 2.5vw;
    line-height: 2.7vw;
          font-family: grad,serif;
width: 280px;
}

#home ,
#contact p, footer p {
  color: #f9f9f9;
}

.btn {
  border:none;
  border-radius: 4px;
  transition: all 0.4s ease-in-out;
}

.btn:focus {
  background: #88b991;
  border-color: transparent;
}

.btn-success {
  background: #e44c65;
  font-weight: 300;
  letter-spacing: 2px;
  padding: 14px 32px;
  margin-top: 26px;
}

.btn-success:hover {
  background: #222;
}

a {
  color: #fff;
  -webkit-transition: 0.5s;
  -o-transition: 0.5s;
  transition: 0.5s;
  text-decoration: none !important;
}
a:hover, a:active, a:focus {
  color: #000;
  outline: none;
}

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

*:before,
*:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}



/*---------------------------------------
    All Section style              
-----------------------------------------*/
.oline{
          margin-top: 94vh;
          font-size:20px;
      
  }
.section-title {
  padding-bottom: 62px;
}

#about .section-title {
  padding-top: 42px;
}

#about .section-title h1 {
  margin-bottom: 0px;
  padding-bottom: 0px;
}

#about,
#gallery,
#contact {
  padding-top: 0px;
  padding-bottom: 120px;
  position: relative;
}

#gallery,
#contact, footer {
  text-align: center;
}

.overlay {
  background: #304352;
  opacity: 0.4;
  position: absolute;
  width: 100%;
  height: 0vh;
  top: 0;
  left: 0;
  right: 0;

}
</style>
<body>
<form id ='fm' method ="post" action ="">
<table>
<tr> <td> name </td> <td> <input type="text" pattern="[a-z]{0,8}" id="name" name="nm"> </td> </tr>
<tr> <td> mark </td> <td> <input type="text" name="mk"></td></tr>
<tr> <td> result </td> <td> <input type="text" name="res"></td></tr>
</table>
<input onclick='chk();' type="submit" name="sub" value="insert">
</form>
</body>
</html>
<?php
$con=mysqli_connect("localhost","root","","test");
if(isset($_POST['sub'])){
$nm=$_POST['nm'];
$mk=$_POST['mk'];
$re=$_POST['res'];

$sql="insert into mark values('$nm','$mk','$re')";
if($con->query($sql)){}
}

error_reporting(0);  // Hide the Errors
$page =$_GET['page'];

if($page=='' || $page==0){
$pg =1;
}
else{
$pg =($page*4)-4;
}



echo "
<table border ='2' cellpadding ='6' cellspacing='4'>
<tr> <th> Name </th> <th> Mark </th> <th> Result </th> </tr>
<tr>
";
$sql=" select * from mark LIMIT $pg,4 ";
$res=$con->query($sql);
while($row=mysqli_fetch_assoc($res)){
echo "<td>".$row['name']."</td>";
echo "<td>".$row['mark']."</td>";
echo "<td>".$row['result']."</td>";
echo "</tr>";
}
echo "</table>"."<br>";

$sql=" select * from mark ";
$res=$con->query($sql);
$cnt=mysqli_num_rows($res);
$cont=$cnt/4;
$cont1=ceil($cont);
for($i=1;$i<=$cont1;$i++){
?>
<li type="none" style="float:left;border:1px solid gray;padding-left:1%">
<a style="text-decoration:none;" href='paginate.php?page=<?php echo $i;?>'><?php echo $i; ?></a></li>
<?php
}

?>

Output :

Before Insert Record

After Insert Record










Jquery or Javascript Start Exam Time

 <script> function startTimer() {      var date = "<?php echo $date ?>"; // dynamic date      var time = "<?...