• 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

    • Sandboxie Plus 1.17.8 / Classic 5.72.8 by Razvan Serea Run programs in a sandbox to prevent malware from making permanent changes to your PC. Sandboxie allows you to run your browser, or any other program, so that all changes that result from the usage are kept in a sandbox environment, which can then be deleted later. Sandboxie is a sandbox-based isolation software for 32- and 64-bit Windows NT-based operating systems. It is being developed by David Xanatos since it became open source, before that it was developed by Sophos (which acquired it from Invincea, which acquired it earlier from the original author Ronen Tzur). It creates a sandbox-like isolated operating environment in which applications can be run or installed without permanently modifying the local or mapped drive. An isolated virtual environment allows controlled testing of untrusted programs and web surfing. Sandboxie is available in two flavors Plus and Classic. Both have the same core components, this means they have the same level of security and compatibility. What's different is the user interface the Plus build has a modern Qt based UI which supports all new features that have been added since the project went open source. The Classic build has the old no longer developed MFC based UI, hence it lacks support for modern features, these features can however still be used when manually configured in the Sandboxie.ini. Sandboxie Plus 1.17.8 / Classic 5.72.8 release notes: Added added DisableCustomTitleOpt=[process,][y|n] to allow [#] sandboxie title markers on custom-titlebar windows (Delphi VCL, Qt, Electron) that were previously skipped to prevent DWM repaint CPU loops #5387 Changed updated bundled ImDisk driver to 3.0.2 #5419 Fixed fix Suppress logs for expected non-user SIDs #5422 SbieSvc.exe: SBIE2218/2219 error when run program as administrator #5417 fixed explorer.exe crashes in Application Compartment when Huorong Security is installed #5423 Download: Sandboxie Plus (64-bit) | 23.5 MB (Open Source) Download: Sandboxie Classic (64-bit) | 3.0 MB Links: Sandboxie Website | GitHub | ARM64 | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Hello, Christian Maas' XVI32 is a nice (and very small) hex editor. Speaking of hex editors, many years ago a colleague and I who both worked at Tribal Voice managed to edit a copy of the company's PowWow instant messaging client to make it behave better now that all of its lookup servers and other server-side tech was gone.  The program didn't support NAT (RFC-3022 was introduced in January 2001, the same time Tribal Voice was shuttered), but it still worked okay if you manually set up port-forwarding on your router.  The server at http://powwow.jazy.net/ hosts a copy (usual warnings about downloading and running untrusted code from random internet servers apply). I occasionally use some tools like Funduc Software's Search and Replace and Application Mover when I need to make mass-edits to text-based files or move programs with a hard-coded installation directories, respectively.  When I need to figure out the exact LCD panel inside of a laptop, EnTech Taiwan's Monitor Asset Manager is my go-to tool for that purpose. JD Design's website (now hosted on github.io) has a number of interesting freeware and shareware utilities.  I used to use their TouchPro utility to set the file timestamps on software I was mastering to match its version number (e.g., version 3.00 of a program had all of its files dates set to 3:00AM, and so forth). Karenware has a number of interesting freeware utilities, too. Regards, Aryeh Goretsky  
    • I still use HexChat! Not really as ancient as the 1994 AutoCAD above my post, but I have never found anything better to replace it. Yes we still operate an IRC server https://www.neowin.net/irc/ 😛 
    • At work we still have a couple of people that use a version of AutoCAD LT purchased in 1994. This predates Windows 95 and works fine on versions of Windows up to XP. Its long since run in an locked down isolated XP VM, accessible via RDP. I did install LibreCAD for them, however they said it was just too different to get to grips with. In all fairness one of them is now 75 and the other is almost 60.
    • On my music making (non internet) PC Sony Acid Pro 7.0 Adobe Audition 2015 Korg Legacy Collection Windows 7 SP1
  • 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
      509
    2. 2
      +Edouard
      198
    3. 3
      PsYcHoKiLLa
      138
    4. 4
      ATLien_0
      90
    5. 5
      Steven P.
      82
  • Tell a friend

    Love Neowin? Tell a friend!