• 0

login display username


Question

Recommended Posts

  • 0

It would be beneficial to not only yourself, but the many helpful people on Neowin if you made one topic and kept in in it. Your never going to get support if you constantly keep creating topics.

To answer your question; it depends how your login system works. Form your previous posts, I believe your using sessions, so it would simple work as follows:

echo 'Hello: '.$_SESSION['username'];

(Replace username with whatever your usernames session is stored as. And keep the ''.

  • 0

It would be beneficial to not only yourself, but the many helpful people on Neowin if you made one topic and kept in in it. Your never going to get support if you constantly keep creating topics.

To answer your question; it depends how your login system works. Form your previous posts, I believe your using sessions, so it would simple work as follows:

echo 'Hello: '.$_SESSION['username'];

(Replace username with whatever your usernames session is stored as. And keep the ''.

Thanks, how would i place this within my code. its for my home page and at the moment its just coming up as text on the page.

  • 0

well without the code you are using we cannot help now can we?

Okay i have just copied the table it is in

        <tbody>
          <tr height="54" valign="top">
            <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
              <br/>
              <a href="Untitled1.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Home</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong> | Forum | </strong> </font>
              <a href="Untitled3.html"></a>
              <a href="Untitled3.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Hottest Uni's</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong>|</strong> </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>
                  <a href="Untitled3.html">
                    <font size="4" face="Tempus Sans ITC">
                      <strong>Rate your Uni </strong>
                    </font></a>
                </strong>
              </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>| Uni LAD test | Events |</strong> </font>
              <a href="Untitled6.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Buy</strong> </font></a>            <font size="4" face="Tempus Sans ITC"> echo 'Hello: '.$_SESSION['username'];</td>
          </tr>
        </tbody>
      </table><br/><br/><br/></div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="250" align="right" height="495">
          <tbody>

  • 0

Uh, this is just HTML code. What Tjcrazy provided you with was some PHP.

What kind of system are you using as a backend? I assume it's some kind of forum system. How do you handle the login and how do you store the user details?

  • 0

Yes the login and registration page work 100% fine. I thought maybe it was for .php page but the page i have at the mo for my homepage is .HTML so should i change the file type?

For my database i use XAMPP which has myphp and mySQL etc

for login / registration i use seperate .PHP files

  • 0

jamessyfx is correct, the code I gave was for a .php file.

From what I've seen in your stupid-amount of previous topics, The code I gave you should work with your system. Obviously, without your entire .html file, I can't give you the full code, but this should work:

        <tbody>
          <tr height="54" valign="top">
            <td style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px">
              <br/>
              <a href="Untitled1.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Home</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong> | Forum | </strong> </font>
              <a href="Untitled3.html"></a>
              <a href="Untitled3.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Hottest Uni's</strong> </font></a>
              <font size="4" face="Tempus Sans ITC">
                <strong>|</strong> </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>
                  <a href="Untitled3.html">
                    <font size="4" face="Tempus Sans ITC">
                      <strong>Rate your Uni </strong>
                    </font></a>
                </strong>
              </font>
              <font size="4" face="Tempus Sans ITC">
                <strong>| Uni LAD test | Events |</strong> </font>
              <a href="Untitled6.html">
                <font size="4" face="Tempus Sans ITC">
                  <strong>Buy</strong> </font></a>      
      <font size="4" face="Tempus Sans ITC"> <?php echo 'Hello: '.$_SESSION['username']; ?></td>
          </tr>
        </tbody>
      </table><br/><br/><br/></div>
    <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
      <div style="TEXT-ALIGN: left; PADDING-BOTTOM: 0px; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
        <table style="BACKGROUND-COLOR: #ffffff" border="1" cellspacing="2" cellpadding="2" width="250" align="right" height="495">
          <tbody>

Change the file extension to .php and make sure at the very top of the page you have:

<?php
session_start();
?>

I'm happy to give help, but also should comment on your website structure. The HTML tables you used... awful.

  • 0

Come on guys, let's wind back the "rawr" somewhat. ;)

Hopefully, louismoore16 will realise the, awesome and free, skills that you guys are offering up and will be as helpful as they can.

Anthony.

I made clear my favourite part of that post ;)

Error

Notice: Undefined index: username in C:\xampp\htdocs\mywebsite\Untitled1.php on line 146

You haven't changed the $_SESSION variable to the name of your session. Because I'm a nice, friendly chap; I looked at a previous post and deduced that your variable is 'myusername'.

So simply, change

$_SESSION['username']

TO

$_SESSION['myusername']

  • 0

I made clear my favourite part of that post ;)

You haven't changed the $_SESSION variable to the name of your session. Because I'm a nice, friendly chap; I looked at a previous post and deduced that your variable is 'myusername'.

So simply, change

$_SESSION['username']

TO

$_SESSION['myusername']

im affraid its still displaying the same message

  • 0

It would be helpful if you gave us the rest of the code. Us friendly guys struggle to help when we can't find out whats wrong.

That error code is gone now, its now saying

Notice: Undefined variable: _SESSION in C:\xampp\htdocs\mywebsite\Untitled1.php on line 142

do you still need code?

  • 0

Back so soon

Parse error: syntax error, unexpected T_DNUMBER in C:\xampp\htdocs\mywebsite\logout.php on line 3

<?php   

if (isset($_SESSION['loggedIn')) {   

$tmp = $_SESSION['myusername'];   
session_destroy();   
session_regenerate_id();   
$_SESSION['userName'] = $tmp;   
}   
?>  

  • 0

<?php   

if (isset($_SESSION['loggedIn'])) {   

$tmp = $_SESSION['myusername'];   
session_destroy();   
session_regenerate_id();   
$_SESSION['userName'] = $tmp;   
}   
?>  

Use that. You were missing a ']'.

What should i change 'if (isset($_SESSION['loggedIn'])) ' too coz i took this code of a website and i dont think it is relevant to mine

Also it is still displaying the same message

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Uhm, that's every business ever, though. It doesn't matter if a bajillion users are using it. As long as it's not making bank, it's probably headed for the graveyard.
    • Yeah Patchou was an active member here, good ol' times indeed.
    • Samsung is the new Google... they don't care if millions of people are using it.
    • Still no word on Tides of Annihilation...... so weird that it wasn't shown at the big Game Fest. Guess I'll put it in the bin like Judas and Squadron 42.
    • Samsung is shutting down yet another app used by millions by David Uzondu Samsung has announced that it is shutting down Samsung Max, its VPN service used by more than 50 million people, effective today. Samsung Max VPN, if you don't know, was an Android app born on February 23, 2018, out of the ashes of Opera Max, a very popular data-saving VPN that Opera had discontinued the previous year. Samsung bought the discontinued service, rebranded it, and added a native Samsung UI to fit the Galaxy ecosystem. The app could do things like compress images, help you manage background data on a per-app basis, reduce video data consumption, shrink music files, optimize webpages, block advertisement trackers in incognito mode, and encrypt your internet traffic on public Wi-Fi networks. Image via SammyGuru If you open the app now, you'd be greeted by a shutdown banner warning that all VPN, data saving, and privacy services stopped functioning on June 15, 2026. The creators failed to provide a reason for the shutdown, instead publishing a farewell note that read: "Thank you for being with us over the years. Your support and activity truly meant a lot to us and helped shape this app into what it became." This same message appears on the Google Play Store listing for the app as well. Max VPN is the latest service from Samsung to join the list of discontinued applications from the company. Just two months ago, the Korean tech giant announced that it is completely shutting down Samsung Messages, forcing millions of users to migrate to Google Messages by next month. The only devices that the shutdown won't affect are older smartphones running Android 11 or lower. Some of the features of Google Messages that Samsung hopes will entice users include AI-powered scam detection to block suspicious links, integrated Gemini AI tools to generate quick replies, custom chat bubbles, and universal RCS compatibility for sharing high-quality media with iOS users. The platform also offers seamless syncing across tablets and smartwatches. In addition to that, users gain access to message scheduling, smart classification, and automated category sorting. Via: SammyGuru
  • Recent Achievements

    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      499
    2. 2
      +Edouard
      195
    3. 3
      PsYcHoKiLLa
      125
    4. 4
      Steven P.
      85
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!