Skip to content

Ebhor.com

  • Business Studies
  • Tutorial
    • Spring Tutorial
    • Bootstrap Tutorial
    • The Ultimate CSS Tutorial
    • Mathematics Tutorial
    • JavaScript Tutorial
    • Struts1 Tutorial
    • Hibernate Tutorial
    • JSP Tutorial
    • Best Jquery tutorial
  • java
  • CSS
  • php

login example

PHP Session Example

May 26, 2021July 8, 2018 by manish

Previous post was about PHP Session There explained about session its purpose and syntax in detail. Lets see one good example of session. User login system 1. connection.php This page is used to establish database connection from application.

1
2
3
<!--?php
    $con = new mysqli("localhost","root","","session");
?-->

2. index.php This page retrives the user detail from database

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!--?php
    include "header.php";
    include "connection.php";
if($_POST[em])
{
$sql = "select * from `user` where `email`='$_POST[em]' and `password`='$_POST[pw]'";
$res = $con--->query($sql);
$num = $res-&gt;num_rows;
if($num!=0)
{
$row = $res-&gt;fetch_array();
             $_SESSION[userid] = $row[id];
$_SESSION[chk]    = true;
             header("location:profile.php");  //redirect one PHP file to another PHP file
}
else
{
echo "Login Fail";
}
 
}
?&gt;

Email- Password New User

1
 

… Read more

Categories php Tags login example, php, session

Latest Posts

  • ITI full form | ITI Course Trades Institutes and Job
  • Full form of CSS | Details of CSS
  • Arithmetic operations using switch case and do while loop in C Programming
  • How To Fix Internal Exception: java.io.ioexception In Minecraft
  • Java Jcombobox example set selected item actionlistener  getselecteditem
  • Write a program to find greatest number in a 3*3 array
  • Javascript jquery checkbox checked, unchecked, ischecked
  • Throw and Throws Keywords in Java
  • a cube minus b cube a³ – b³ formula Proof Examples &Applications
  • Java program to add two numbers

Categories

  • angularjs (1)
  • article (1)
  • Blockchain (1)
  • bootstrap (46)
  • Business Studies (13)
  • C (6)
  • c language (1)
  • C Programming (45)
  • C++ (40)
  • chhattisgarh (1)
  • computer graphics (6)
  • computer-basics (3)
  • computer-networks (4)
  • Cryptocurrency (1)
  • CSS (52)
  • full form (8)
  • gk (1)
  • gst (1)
  • Hibernate (10)
  • hql (1)
  • html (15)
  • IoT (1)
  • java (107)
  • javascript (42)
  • jquery (13)
  • json (2)
  • linux (20)
  • Machine Learning (1)
  • maths (47)
  • Minecraft (1)
  • mysql (28)
  • php (40)
  • python (4)
  • scilab (2)
  • seo (1)
  • servlet (14)
  • spring (12)
  • struts1 (14)
  • struts2 (10)
  • symbol (1)
  • tools (1)
  • Uncategorized (9)
  • XAMPP (2)

Pages

  • About Us
  • Contact Us
  • Disclaimer
  • Guest Post
  • Privacy Policy
Copyright By Ebhor.com 2022