• 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.