You are here: Re: [PHP] make it remember « PHP « IT news, forums, messages
Re: [PHP] make it remember

Posted by George B on 08/26/05 03:05

Robert Cummings wrote:
> On Thu, 2005-08-25 at 15:18, George B wrote:
>
>>Robert Cummings wrote:
>>
>>>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.
>>> //
>>>}
>>>
>>>
>>
>>If I do that then i get this error
>>
>>Fatal error: Can't use function return value in write context in
>>myfilename line 2
>>
>>What does that mean.
>
>
> I don't know. I don't think it comes form the snippet I sent you...
> which wasn't meant to be a functional snippet, more of a overview of the
> process.
>
>
>> And one more thing, on the code where it says
>>if( !isset( $_SESSION['userName'] ) )
>>Does that mean that in this code
>>
>><form name="form1" method="" action="">
>>the method is session?
>
>
> No, it would be "post".
>
> It sounds like you don't have a clue what you're doing. You might want
> to read up on forms and sessions using PHP.
>
> Cheers,
> Rob.
nope never worked with sessions before.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация