jacko_162 Posted March 9, 2010 Share Posted March 9, 2010 when a user is logged onto my test site i can echo the following; <?php echo $_SESSION['SESS_MEMBER_ID'];?> i have a new table in my database that i want users to use to add certain data specs but i want the form to include the above "member id" for some reason i cant get it to work as i get all types of syntax errors thrown up in the browser. this is my form code: <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <?php if (isset($_POST['submit'])) { $insert = "INSERT INTO $table1 SET member_id='NEED TO INSERT MEMBER ID HERE', test1='$test1', test2='$test2', test3='$test3', test4='$test4', test5='$test5', test6='$test6', test7='$test7', test8='$test8', test9='$test9', test10='$test10', test11='$test11', test12='$test12', test13='$test13', test14='$test14', date=NOW(), time=NOW()"; if (@mysql_query($insert)) { echo('<div class="msg msg-ok"><p>This item was added successfully</p></div>'); } else { echo('<div class="msg msg-error"><p><strong>oops!</strong> something went wrong, please try again!</p></div>'); }} ?> how can i put in the session variable into the table, or how do i change; <?php echo $_SESSION['SESS_MEMBER_ID'];?> to; <?php $member_id ?> i can then call "$member_id" in other templates if needed. many thanks for any help steve Link to comment https://forums.phpfreaks.com/topic/194604-help-calling-some-information-from-a-session/ Share on other sites More sharing options...
Wolphie Posted March 9, 2010 Share Posted March 9, 2010 Do you have session_start(); at the very top of your script? What are the errors being thrown? Link to comment https://forums.phpfreaks.com/topic/194604-help-calling-some-information-from-a-session/#findComment-1023492 Share on other sites More sharing options...
jacko_162 Posted March 9, 2010 Author Share Posted March 9, 2010 yes i start the seesion at the top of every page. the problem isnt with the code i have at the moment, i didnt explain myself very well ok i wanted to use the session call to insert the result into a table (see php form code above) to do this i want to define $member_id as $_SESSION['SESS_MEMBER_ID']; so i can insert the result into a seperate table in the database. my head hurts Link to comment https://forums.phpfreaks.com/topic/194604-help-calling-some-information-from-a-session/#findComment-1023498 Share on other sites More sharing options...
Wolphie Posted March 9, 2010 Share Posted March 9, 2010 Why not just use $_SESSION['SESS_MEMBER_ID'] to insert it into the table? However // Will give $member_id the value of $_SESSION['SESS_MEMBER_ID']; $member_id = $_SESSION['SESS_MEMBER_ID']; Link to comment https://forums.phpfreaks.com/topic/194604-help-calling-some-information-from-a-session/#findComment-1023501 Share on other sites More sharing options...
jacko_162 Posted March 9, 2010 Author Share Posted March 9, 2010 thank you Link to comment https://forums.phpfreaks.com/topic/194604-help-calling-some-information-from-a-session/#findComment-1023516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.