473,473 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

php sessions

115 New Member
I am creating a forum and i have session running. The session displays the user name in the posts. This is all dandy and i have the user name displaying but the problem is that every time someone else logs in all the user names in the posts change!!!! I am gathering i have to save these somewhere but i have no idea how ? can anyone help?

I have looked at this problem another way but i just keep confusing myself. I have an id attribute in both messages and members table. So i was thinking using the session to store the id and then do a link(in mysql) to get the user name but i keep failing miserably

I would post the code up but it is an assignment i am happy to send it via e-mail so i can log it which would give me backup in case i needed to prove it is my own work.

cheers in advanced
Dec 24 '07 #1
6 1193
pbmods
5,821 Recognized Expert Expert
Heya, truezplaya.

Since there is a one-to-one relationship between posts and authors in this context, your best bet would be to store the author ID in the messages table.
Dec 24 '07 #2
truezplaya
115 New Member
Hey cheers for clearing that point up but how would i get the id from members table which is automatically incremented to save in the messages table? The only way i can think is to let the user pick their own user id and every message they send they have to type that in.

You might gather that i am pretty new to this lol

cheers
Dec 24 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, truezplaya.

Don't worry. We've all been there before.

When the User logs in, you'll want to store his member ID in the $_SESSION.

Then, when the User creates a post, you can retrieve his member ID and save it with the post data.
Dec 24 '07 #4
truezplaya
115 New Member
It is the saving part that i am unsure of!!!!!!!! It's getting to the stage i just feel like throwing my comp out of the window arrrrggggg.
Dec 25 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, Truezplaya.

You'll want to structure your SQL query something like this:
Expand|Select|Wrap|Line Numbers
  1. $_userid = (int) $_SESSION['userid'];
  2. $_postText = mysql_real_escape_string($_POST['postText']);
  3.  
  4. $__sql = "
  5. INSERT
  6.     INTO
  7.         `posts`
  8.     SET
  9.         `posterid` = '{$_userid}',
  10.         `posttext` = '{$_postText}'";
  11.  
and so on.
Dec 25 '07 #6
truezplaya
115 New Member
Thank you very much sorry it has taken a while to reply i have just been making sooooo much progress after getting stopped in my tracks for a while !!!!!!!!

Truez
Jan 17 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: The Plankmeister | last post by:
Hi... I'm trying my hardest to understand fully how sessions work and how best to use them. However, all I can find is information that doesn't tell me anything other than that sessions store...
13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
3
by: Maxime Ducharme | last post by:
Hi group We have a problem with sessions in one of our sites. Sessions are used to store login info & some other infos (no objects are stored in sessions). We are using Windows 2000 Server...
3
by: Will Woodhull | last post by:
Hi, I'm new here-- I've been reading the group for a couple of days. Nice group; I like the way n00b33 questions are handled. I've been using a Javascript routine in index.html to determine a...
2
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use...
12
by: D. Shane Fowlkes | last post by:
This is a repost (pasted below). Since my original post, I've double checked the system clock and set all IIS Session Timeout values to 10 minutes. Still ...the problem occurs. I've also...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
22
by: magic_hat60622 | last post by:
Hi all. I've got an app that dumps a user id into a session after successful login. the login page is http://www.mydomain.com/login.php. If the user visits pages on my site without the www (i.e.,...
13
Frinavale
by: Frinavale | last post by:
One of the most fundamental topics in web design is understanding how to pass information collected on one web page to another web page. There are many different ways you could do this: Cookies,...
3
Atli
by: Atli | last post by:
Introduction: Sessions are one of the simplest and more powerful tools in a web developers arsenal. This tool is invaluable in dynamic web page development and it is one of those things every...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.