Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using session variables on a form

New Here ,
Jul 22, 2011 Jul 22, 2011
Hi, I'm a bit new to all this. Let me explain what' I'm currently trying to do...


I have a login page, some standard pages and a page with a form that connects through to a database on it.


I have the login functionality working (using the standard dreamweaver user authentication functionality). I want to be able to use the username of the person who has logged in, in one of the form fields (username field) so that they don't have to type it again.

I presume that the user details are kept in some kind of session parameter, and I need to reference this on the form - but how do I do it!?


The code in the form is:


GetSQLValueString($_POST['user_id'], "int"),
GetSQLValueString($_POST['game_id'], "int"),
GetSQLValueString($_POST['game1_home'], "int"),
GetSQLValueString($_POST['game1_away'], "int"),
GetSQLValueString($_POST['game2_home'], "int"),


The line in bold is where I need it to reference the username.


I can post the user authentication code if required (I use the standard dreamwqeaver functionality, and the form page above has the user authentication check code on it) - as I say I'm stumbling my way through this so would really appreciate any help!


Many thanks,
Darren

TOPICS
Server side applications
328
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 22, 2011 Jul 22, 2011
LATEST

A session variable lives until the session is closed, so when they close their browser, they would need to log in again.

To create the session variable you could do this

$_SESSION['user_id'] = $_POST['user_id'];

Then to make is even easier, you can put it into a variable

$sid=$_SESSION['user_id'];

gary

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines