Switch to full style
Project under GPL source codes are posted here
Post a reply

Login page using sessions and mysql in php

Mon Feb 13, 2017 6:54 am

This is simple examlple on how to use PHP Sessions to login along with using Mysql database.
Code:
<?php
session_start();
include("connection.php");
$_SESSION['user'] = $_POST['uname'];

$_SESSION['uname'] = $_POST['uname'];
$_SESSION['pass'] = $_POST['pass'];
?>
<html>

<body>
<form method="POST">
username:<input type="text" name="uname" id="uname"></br>
password:<input type="password" name="pass" id="pass"></br>
<input type="submit" name="submit" id="submit">
</form>

<?php

if(isset($_POST['submit'])){
   
   
   
   $name= $_SESSION['uname'];
   $pass= $_SESSION['pass'];
$sql = mysql_query("SELECT * FROM `users` WHERE username ='$name' or password = '$pass'");
if($r = mysql_fetch_row($sql)){
   header("Location:welcome.php");
}   
else{
   echo "bye";
}
}
?>
</body>

</html>



Attachments
sessions.rar
Login page using sessions and mysql in php
(1.08 KiB) Downloaded 719 times

Post a reply
  Related Posts  to : Login page using sessions and mysql in php
 develop a login page- login servlet - ServletContext     -  
 Login using session with php and mysql     -  
 track session from login page-J2EE project     -  
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 login using jsp     -  
 login using Ajax     -  
 Ajax Login     -  
 php login with session     -  
 ASP.NET 2.0 Login Controls     -  
 code for login by jsp and ajax     -