• 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

    • Nothing is stopping you from continuing with your testing cadence. If updates are released every 2 weeks instead of 4, and you test once every 4 weeks, the exact same amount of patches will still be available for you in those 4 weeks. For example: Before 4th week - patch 1, 2, 3, 4 After 2nd week - patch 1 and 2 4th week - patch 3 and 4 Still the same amount after 4.
    • Everyone else has said it. I'm gonna say it - you don't know what you're talking about. I do. I have two laptops. One work, one personal. I have access to two more laptops - both personal. At home I manually update my personal laptop when I see on Neowin that there is an update - I carry on and only apply the updates when I am ready. My work one only updates when my workplace decides to send it - I carry on and only apply the updates (when they actually arrive, which is usually days after the release) when I switch off the laptop at the end of the day as usual. The two other personal laptops only get updated when I get to it which is rarely - the people who own them carry on using them until I get to it and update them. All of the browsers on all laptops are configured to restore the tabs when launched. Google and Microsoft have changed from 6 weeks to 4, and it looks like it's going to move to 2. None of these changes affect how any of these browsers on the laptops are used. Not one jot. My advice to you is stop panicking whenever you see an update. Just carry on with what you're doing. This even benefits you in a way - from your comment you sound like you don't like the changes or the frivolous new features - great - then carry on as before!
    • AMAZON needs to take total accountability for this.
    • Server Summit had a heap of announcements, ADCS changes are baller.
    • Nice, hope they *finally* fixed the issue with the NTFS driver where the system would completely brick during large file copies using the built in driver. It's been broken for years requiring me to use the older, slower, NTFS-3G FUSE driver.
  • Recent Achievements

    • 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
    • One Month Later
      AndreaB earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      197
    3. 3
      PsYcHoKiLLa
      138
    4. 4
      ATLien_0
      90
    5. 5
      Steven P.
      80
  • Tell a friend

    Love Neowin? Tell a friend!