Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Retrieving a username from MYSQL (??)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Deezi" data-source="post: 392699" data-attributes="member: 72342"><p>I want something like this:</p><p><img src="http://i.imgur.com/vGaQDmP.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>I already have a login form, a session started, but no idea how to make username & rank appear, tried searching for a while, but can't find something that actually works..</p><p></p><p>So I was wondering if anyone here could help me..</p><p></p><p></p><p>Have a nice day<img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p><p></p><p><span style="color: #ff0000"><strong>*Thread can be closed, I figured this out.</strong></span></p><p><span style="color: #ff0000"></span></p><p><strong><span style="font-size: 22px"><span style="color: #00b300">SOLUTION</span></span></strong></p><p><span style="color: #404040"><span style="font-size: 15px">So the solution was much more simple than I though, atleast for me.</span></span></p><p><span style="color: #404040"><span style="font-size: 15px">in your login file where you start the "$_SESSION[' ']" you just need to add another session called </span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px">$_SESSION['uid'] = $row['uid'];</span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"><em>// Row is the MYSQL database row in which the username is located, is not uid for everyone it's whatever you called the MYSQL row where usernames are located, and you could also use a number if you want. $_SESSION['uid'] is the name of the session, which I do believe you can call whatever you want.</em></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"><em>[SPOILER="Screenshot"][/SPOILER]</em>[SPOILER="Screenshot"]</span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"><em><img src="http://i.imgur.com/EdTDJkf.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </em></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px">[/SPOILER]</span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px">After adding this session, you really only have to add it to your page ( I added to sidebar )</span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"> <div id="username"><?php echo $_SESSION['uid']; ?></div></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"> <div id="rank"><p><i><?php echo $_SESSION['rank']; ?></i></p></div></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"><em>// I do believe the <div>'s are not needed, I just added them so I could edit positions and such with CSS.</em></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px">Then you might see it disappearing, which is actually good in this case, because when I first did it I starting trying to edit everything, which is something I realised I didn't have to do. After editing everything, I thought I'd just relog, so that I could see if the login & registration was still working, which was working just fine, and when I logged in, as that started a <strong>new session </strong>with the new $_SESSION[' '] that I added to the login page, and it was working fine.</span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"><img src="http://i.imgur.com/VuEL9ej.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </span></span></p><p><span style="color: rgb(64, 64, 64)"><span style="font-size: 15px"></span></span></p></blockquote><p></p>
[QUOTE="Deezi, post: 392699, member: 72342"] I want something like this: [IMG]http://i.imgur.com/vGaQDmP.png[/IMG] I already have a login form, a session started, but no idea how to make username & rank appear, tried searching for a while, but can't find something that actually works.. So I was wondering if anyone here could help me.. Have a nice day:) [COLOR=#ff0000][B]*Thread can be closed, I figured this out.[/B] [/COLOR] [B][SIZE=6][COLOR=#00b300]SOLUTION[/COLOR][/SIZE][/B] [COLOR=#404040][SIZE=4]So the solution was much more simple than I though, atleast for me. in your login file where you start the "$_SESSION[' ']" you just need to add another session called [/SIZE][/COLOR] [COLOR=rgb(64, 64, 64)][SIZE=4]$_SESSION['uid'] = $row['uid']; [I][/I] [I]// Row is the MYSQL database row in which the username is located, is not uid for everyone it's whatever you called the MYSQL row where usernames are located, and you could also use a number if you want. $_SESSION['uid'] is the name of the session, which I do believe you can call whatever you want.[/I] [I][/I] [I][SPOILER="Screenshot"][/SPOILER][/I][SPOILER="Screenshot"] [I][IMG]http://i.imgur.com/EdTDJkf.png[/IMG] [/I] [/SPOILER] After adding this session, you really only have to add it to your page ( I added to sidebar ) <div id="username"><?php echo $_SESSION['uid']; ?></div> <div id="rank"><p><i><?php echo $_SESSION['rank']; ?></i></p></div> [I]// I do believe the <div>'s are not needed, I just added them so I could edit positions and such with CSS.[/I] Then you might see it disappearing, which is actually good in this case, because when I first did it I starting trying to edit everything, which is something I realised I didn't have to do. After editing everything, I thought I'd just relog, so that I could see if the login & registration was still working, which was working just fine, and when I logged in, as that started a [B]new session [/B]with the new $_SESSION[' '] that I added to the login page, and it was working fine. [IMG]http://i.imgur.com/VuEL9ej.png[/IMG] [/SIZE][/COLOR] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Retrieving a username from MYSQL (??)
Top