Total members 11657 |It is currently Tue Aug 22, 2017 6:30 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka






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:
File comment: Login page using sessions and mysql in php
sessions.rar [1.08 KiB]
Downloaded 76 times
Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  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     -  
 Ajax Login     -  
 php login with session     -  
 ASP.NET 2.0 Login Controls     -  
 login using Ajax     -  
 Cookie based login in php     -  











Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team