Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jul 2005
Posts: 3
Lurker
Lurker
Offline
Joined: Jul 2005
Posts: 3
First of all, though an experienced programmer (VB, C, C#, REXX and a bunch of other languages), I'm a total PHP virgin and fairly new to UBB Threads, so please excuse me if I'm missing something obvious here.

I'm trying to tie some stuff together (for the moment it's my own dynamically threaded chat, but more will follow) and need to get the name of the logged in user. After digging around in the UBB source and these forums, I found that it seems to be stored in $user['U_Username'] and $CheckUser.

So far so good. The problem is that when I access them, they come up empty, which leads me to believe that I should include something where these are defined. Three hours of digging through the source and I still can't find it.

I've narrowed it down in this simple script:

Code
 <br /><html><br />  <head><br />    <title>Test</title><br />  </head><br />  <body><br />    <p><br />      <?<br />        echo 'Test string';<br />        echo $user['U_Username'];<br />        echo $CheckUser;<br />      ?><br />    </p><br />  </body><br /></html> 


This script results in "Test string" and nothing else. As I said, I'm probably just missing something obvious because I'm staring in the wrong place, but this silly problem has me stuck.

What am I doing wrong and how should I fix it?


/Troberg
Sponsored Links
Joined: Feb 2001
Posts: 2,268
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 2,268
First you have to require the library:

Code
 // Require the library<br />require ("./includes/main.inc.php"); 


Then you have to use the authenticate user function:

Code
 $userob = new user;<br />$user = $userob -> authenticate(); 


Then you could do something like this:

Code
 isset($user['U_Username']) && $Username = $user['U_Username']; 


and that would give you the user name

Note: The authenticate function will give you: U_Username,U_Password,U_SessionId, U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number, U_Banned,U_LastOn, and U_OC_Userid plus it can accept input from you on a lot of other user data (just take a look at the showflat.php file for an example of what you can pull out of the database).

Joined: Jul 2005
Posts: 3
Lurker
Lurker
Offline
Joined: Jul 2005
Posts: 3
Thanks, worked like a charm. Would have taken me a while to figure out. PHP is syntactically a bit different from what I'm used to, and up til now I've just modified existing PHP code. It needs a decent editor also to color code it, otherwise it quickly starts to look like ASCII art when mixed up with HTML...

Once again, thank you.


/Troberg
Joined: Feb 2001
Posts: 2,268
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 2,268
PHP is kinda like "coding in shorthand" and a lot of the commands are condensed -it confused me at first and I had some experience in perl!

Glad I could help.

Joined: Jul 2005
Posts: 3
Lurker
Lurker
Offline
Joined: Jul 2005
Posts: 3
What makes PHP messy in my head is not the "shorthand-effect". It's that my head has trouble switching back and forth between HTML and PHP. I'm going to try to get my editor to use a different colored background for PHP and HTML, that should make some of the "special character alphabet soup" a bit clearer.

My chat works fine now, feel free to check it out at http://rpglab.net/index.php. It's in Swedish, but if you click on "chat", click on the link that appears, get the file, then click chat again it should work nicely even if you don't speak Swedish.

Edit: No need to register a user, just set your name in chat options.

It is IE only for the moment, but if you don't use IE, the file you downloaded also contains a windows stand-alone client.

As far as I know, it is the only threaded chat today. The oldest entries will be removed (200 kept, can be changed by the user), causing the threads to dynamically grow and adapt to the discussion. Difficult to explain, but works really nicely.

Last edited by Troberg; 08/11/2005 1:30 PM.

/Troberg
Sponsored Links
Joined: Feb 2001
Posts: 2,268
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 2,268
I use CuteHTML and it color codes the script pretty well.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)