Total members 11895 |It is currently Wed Dec 18, 2024 6:40 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 804 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     -  
 login using Ajax     -  
 Ajax Login     -  
 php login with session     -  
 ASP.NET 2.0 Login Controls     -  
 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
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com