Re: make it remember

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2005-08-25 at 00:19, George B wrote:
> Robert Cummings wrote:
> > On Thu, 2005-08-25 at 00:10, George B wrote:
> > 
> >>Ok, I am doing a sort of a project right now... It is like a php chat 
> >>room that records every message into a database. Now, on the first post 
> >>I want it to like set the name, so on first post it would say Name: and 
> >>you set your name, then on every other message you post it just says 
> >>Posted by and remembers your name from the last entry. Is this anyhow 
> >>possible?
> > 
> > 
> > Check session... if no name, display name prompt, otherwise don't
> > display name prompt.
> > 
> > Cheers,
> > Rob.
> which would I choose.
> http://us2.php.net/manual-lookup.php?pattern=sessions


In brief:

if( isset( $_POST['userName'] ) && !empty( trim( $_POST['userName'] ) )
)
{
    //
    // Save userName to session.
    //
    $_SESSION['userName'] = trim( $_POST['userName'] );
}

if( isset( $_POST['message'] ) && !empty( trim( $_POST['message'] ) )
    &&
    isset( $_SESSION['userName'] ) )
{
    //
    // Handle submission of message.
    //
}

if( !isset( $_SESSION['userName'] ) )
{
    //
    // Display user name prompt.
    //
}


-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux