Jump to content

NOOB ?


Greaser9780

Recommended Posts

[quote author=Greaser9780 link=topic=106005.msg423670#msg423670 date=1156806858]
Must I start a db connection in order to get a session to start?
[/quote]

No. You do not need to utilize a database to make use of sessions or session variables.
Link to comment
Share on other sites

OK then I have a welcome message set to come up when my page loads. It is supposed to echo Welcome! and then display the username that was used to login. It only displays Welcome! and appears that the username is not being called. Here is the PHP part of the page:
<?
session_start();

echo "Welcome ". $_SESSION['username'] ." 
    <br /><br />";

?>
Link to comment
Share on other sites

<?
session_start();
echo "Welcome ". $_SESSION['username'] ."
    <br /><br />";

?>
I'm not sure what you mean. I have a very limited background in PHP and up till recently most was copy and paste then edit where I had to.  This script worked before when it was called by an include message and this script was labeled welcome.php
Link to comment
Share on other sites

Here is a way to define it by typing your username in the box hitting submit:
(I said I was putting it together - )

[code]<?php
session_start();
$_SESSION["username"] = $_POST["username"];
{
echo "Welcome ". $_SESSION['username'] ." ";
}
?>

<form action="" method="POST">
<input type="text" name="username">
<input type="submit">
</form>[/code]
Link to comment
Share on other sites

[quote author=Greaser9780 link=topic=106005.msg423685#msg423685 date=1156807921]
Another noob ? How do I define it then. I understand what you are saying but I have about 3-4 comands memerised.
[/quote]

Well, 'somewhere' in your login script the username is obtained.  Suppose it was known as the variable $wombat.  Then .... drum roll:

[code]$_SESSION['username'] = $wombat;// save the username in a session variable[/code]
Link to comment
Share on other sites

Thank you andyB. Finally it worked I couldn't use $_POST['username'] because the form was already handled in my checkuser.php file. I looked up how it was defined in there and VOILA!! SUCCESS!!!
Gosh you people are smart.  Only my first week. Hard to learn it and build the site at the same time. Thank you for your cooperation. :) :) :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.