Jump to content

[SOLVED] Retreive Member's username


Pavlos1316

Recommended Posts

Hi

 

1st code is used in my login.php so combined with the next code which is placed in my members pages are used for user authentication:

 

if(mysql_num_rows($result)>0){
//Login Successful
//Regenerate session ID to
//prevent session fixation attacks
session_regenerate_id();
$member=mysql_fetch_assoc($result);
$_SESSION['SESS_ID']=$member['ID'];
//Write session to disc
session_write_close();
header ("location: members_area.php");
exit();

 

 

<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_ID']) || (trim($_SESSION['SESS_ID'])=='')){
header("location: http://www.sonophoenix.com/");
exit();
}
?>

 

Now I have another procces.php which is submitting a form that only a member can submit.

 

How can I get the member's username in my db when submitting the form?

 

Thanks

Link to comment
Share on other sites

ok i would do this  .. chnage where appropriate

 

<?php $getruser="Select username from users where id='".$_SESSION['SESS_ID']."' "; //getting user with id... change select "username - to what ever users are in db" and "users - what ever users are"
$getuser2=mysql_query($getuser) or die("Could not get replies");
while($getuser3=mysql_fetch_array($getuser2))
{

echo $getuser3['username']; }// chnage to what it is in you

Link to comment
Share on other sites

My code is too big [300 lines]

 

I thing I know where the problem is but I don;t know how to fix it.

 

Here is the situation

 

1. my procces.php connects with db2 takes data from the form and post them in db2.

 

2. username exists in db1. so to retreive id I have to make a connection with db1. Right?

 

Plus I have to post it in db2

 

3. how is that done in the same php file??

Link to comment
Share on other sites

you have to have to create two connect.php files one for each db and include both the files then you can call both db in the page you want to use them both with.  Then you just write the code in the order that you want the events to occur, i believe.  I just did something like this a short while back but cant find the code cause my laptop crashed

Link to comment
Share on other sites

Did it!!! ;D in the same php file

 

<?php

 

1st i connected to my db1 where the username is>>>>> use your code to retreive member's username>>>>and close my db1 connection with mysql close();

 

Then I connected to my db2 which stores the form info.

 

And it's done!!!

 

With your CODE help....!!!!

 

Thanks...!

 

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.