Jump to content

Hello [[name]]


turnej

Recommended Posts

Hi I have a page which I have password protected via my hosting cpanel and given every user a different id and password, is there anyway I can utilise the name of the person logged in and display it on my site - so for example when a particular person logs in it will say hello [[name]], I also want to capture the users name to post to a my sql table - any help gratefully received.

Link to comment
https://forums.phpfreaks.com/topic/233130-hello-name/
Share on other sites

Use sessions.  Include this at the top of every page:

 

<?php

session_start();

?>

 

Then, when a user logs in, set a session variable.

 

<?php

$_SESSION['name'] = $name // Or whatever you have it named

?>

 

That variable will "carry over" onto every page as long as you have session_start() at the top.

 

<?php

echo "Hello, {$_SESSION['name']}!";

?>

Link to comment
https://forums.phpfreaks.com/topic/233130-hello-name/#findComment-1198950
Share on other sites

Hi

 

Thanks for your reply when you say 'whatever you have it named' is this the user field? I don't really follow - How do I tell the page where to get the variable from i.e. the user name for log in from my cpanel?

 

Sorry I am sure this is very simple I am a complete beginner and just trying to get started with php thanks again

Link to comment
https://forums.phpfreaks.com/topic/233130-hello-name/#findComment-1198960
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.