
Originally Posted by
xgreenberetx
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.