Driving me crazy

earthinc

Banned
Messages
104
Reaction score
1
Points
0
Hi
I'm trying to simply make my link that says Login change to "Welcome, [membername]", and the option to log out, when they are logged in. Can I please get some help with this??? :dunno:
 
Last edited:

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
Check out this article: http://www.howtodothings.com/computers-internet/how-to-make-a-login-system-for-your-website

It should explain everything you need to know. I tried to answer this question myself, but it is way too general. When asking a question, it should be pretty specific. Some examples would be to ask where to learn how to make a login system, or why you are having problems making yours with the problematic code in your post. It just makes it easier to answer :)
 
Last edited:

xgreenberetx

New Member
Messages
57
Reaction score
1
Points
0
if you are using php you can do.
Code:
<?php
if(!isset)
{ 
echo "welcome, Guest";
//show the login form
 }
else
{
 echo "welcome, $username";
 }
?>

There is more to this of coarse but it is an outline.
 
Last edited:

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
if you are using php you can do.
Code:
<?php
if(!isset)
{ 
echo "welcome, Guest";
//show the login form
 }
else
{
 echo "welcome, $username";
 }
?>

There is more to this of coarse but it is an outline.

Code:
if(!isset($_GET['user']))
{ 
echo "welcome, Guest";
//show the login form
 }
else
{
 echo "welcome, $username";
 }
The isset function checks whether a variable is set. GET and POST variables are automatically filled out when you submit a form. I think you meant to check whether the user submitted a form by checking whether a certain form variable has been set (corrected above). However, if you want the user name to be remembered on page refresh, you would have to store it is a session (or some other data keeper).
Code:
session_start();

if (!isset($_GET['user']) && !isset($_SESSION['user'])) {
  echo 'Welcome, guest.';
  //Display form
} else if (isset($_GET['user']) && !isset($_SESSION['user'])) {
  $_SESSION['user'] = $_GET['user'];
  echo 'Welcome, ' . $_SESSION['user'];
} else {
  echo 'Welcome, ' . $_SESSION['user'];
}
The next step would be to use a database to verify the user name is registered with your site.

More information:
http://w3schools.com/php/php_get.asp
http://w3schools.com/php/php_sessions.asp

I would recommend completing at least the w3schools tutorial in PHP before continuing. You cannot effectively understand a script if you are not versed in PHP's basics.
 
Top