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

How do I insert a session variable into a record?

Explorer ,
Oct 21, 2006 Oct 21, 2006

Copy link to clipboard

Copied


I can’t figure out how to insert the value passed by a session variable into a record.

I have a form I want to use to insert a record. I pass session variables to this page and want to insert one of them into the record. The session information is:

session_start();
{
$_SESSION['usename'] = $_POST['username'];
$idvar = $_SESSION['id'];
}

$_SESSION[‘id’] is the user_id that I want to insert into the record.

I know $idvar is getting to the page with the form because I can echo it.

The insert code looks like this:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "register")) {
$insertSQL = sprintf("INSERT INTO h_genres (user_id, username, contrib_to, Advertising, Annual_Reports, Leader_Content, Member_Content, Brochures) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['user_id'], "int"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['contrib_to'], "text"),
GetSQLValueString(isset($_POST['Advertising']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Annual_Reports']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Leader_Content']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Member_Content']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['Brochures']) ? "true" : "", "defined","'Y'","'N'"));

mysql_select_db($database_hauw, $hauw);
$Result1 = mysql_query($insertSQL, $hauw) or die(mysql_error());
}

I have a hidden field for the user_id:
<input name="user_id" type="hidden" id="user_id" />

I think I need to get the value in $idvar into user_id but I don’t know how.
Any help is appreciated.
TOPICS
Server side applications

Views

256
Translate

Report

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
LEGEND ,
Oct 21, 2006 Oct 21, 2006

Copy link to clipboard

Copied

LATEST
awsweb wrote:
> I have a hidden field for the user_id:
> <input name="user_id" type="hidden" id="user_id" />
>
> I think I need to get the value in $idvar into user_id but I don?t know how.

<input name="user_id" type="hidden" id="user_id" value="<?php echo
$idvar; ?>" />

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

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