Web Design and Development Forums

[SOLVED] Php Sessions

This is a discussion on "[SOLVED] Php Sessions" within the PHP Forum section. This forum, and the thread "[SOLVED] Php Sessions are both part of the Program Your Website category.

Old Apr 27th, 2008, 15:31   #1 (permalink)
New Member
 
Join Date: Apr 2008
Location: UK
Age: 30
Posts: 2
[SOLVED] Php Sessions

Hi,

I have created a website with a registration form & login form and a uniqueId mysql database to validate the user trying to login. Once user is successfully logged in they are directed to a page were i would like there details to auto display from the database.

I no i have to use sessions but am having trouble understanding could someone help me.

Here is my working login form:

PHP: Select all

<?php
ob_start
();
$host="localhost"// Host name 
$username="web36-dbelite"// Mysql username 
$password="longstand"// Mysql password 
$db_name="web36-dbelite"// Database name 
$tbl_name="tbl_worker"// Table name 

// Connect to server and select databse.
mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername stripslashes($myusername);
$mypassword stripslashes($mypassword);
$myusername mysql_real_escape_string($myusername);
$mypassword mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE workerusername='$myusername' and workerpassword='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");

 
header("location:   Your_account.php  " );
}
else {
echo 
"Wrong Username or Password";
}

ob_end_flush();
?>
peter12345 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 27th, 2008, 16:50   #2 (permalink)
New Member
 
Join Date: Apr 2008
Location: UK
Age: 30
Posts: 2
Re: Php Sessions

Solved my problem! Ar u learn to quickly & take a couple of weeks of and u forget stuff all to soon...

This post is closed.
peter12345 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sessions djme PHP Forum 4 Feb 25th, 2006 12:10
xsl, php sessions (please help) marco_van_mayo Java, JSP, Cold Fusion 0 Feb 19th, 2006 14:35
php sessions fragalot PHP Forum 7 Nov 8th, 2005 20:43
PHP Sessions benbacardi PHP Forum 5 Aug 28th, 2005 09:29
Sessions vor ASP.NET Forum 3 Aug 19th, 2003 20:10



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:18.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59