Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 18th, 2005, 06:38 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to register a variable with session

Hi,

i was wondering if any one can help me? i have a logon form that asks the user for their username and password. upon clicking login a second form is displayed showing all their details from the database. how do i store their Account ID taken from the database in a session and carry it forward to third form where i insert it to a different table in the mysql db.

Thanks in advanced

Scoobie

Reply With Quote
  #2 (permalink)  
Old March 18th, 2005, 11:00 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this something along the line of this: this is just a sample code, so you might want to give your hands a try.

//get the $username and $password from the field. you can try doing an md5 on the pass variable if thats how you saved it;
$query = "select * from users where username = '$username' AND password = '$password'";

and then you can use this to save it in the session variable:

$query2 = mysql_query($query);

while ($row = mysql_fetch_assoc($query2)){


$_SESSION['somename'] = $row['somenamefrommysql'];
$_SESSION['anothername'] = $row['someothernamefrommysql'];
}

that should save it in the session: make sure you start the session at the beginning the page by
session_start();

hope that helps...
post code if not working




----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
Reply With Quote
  #3 (permalink)  
Old April 20th, 2005, 10:21 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you very much it works great

scoobie

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Variable youyou_hym Dreamweaver (all versions) 4 January 20th, 2005 11:48 AM
Session variable anuradha80 General .NET 3 November 4th, 2004 12:39 AM
Session variable mrideout BOOK: Beginning ASP.NET 1.0 1 August 12th, 2004 07:01 PM
Session Variable mcdowell BOOK: Beginning ASP 3.0 5 June 20th, 2004 05:47 AM
Error with variable..maybe register globals codefinder Beginning PHP 1 November 19th, 2003 03:31 PM



All times are GMT -4. The time now is 09:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.