Jump to content

NOOB ?


Greaser9780

Recommended Posts

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
https://forums.phpfreaks.com/topic/18956-noob/#findComment-81930
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
https://forums.phpfreaks.com/topic/18956-noob/#findComment-81932
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
https://forums.phpfreaks.com/topic/18956-noob/#findComment-81939
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
https://forums.phpfreaks.com/topic/18956-noob/#findComment-81941
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
https://forums.phpfreaks.com/topic/18956-noob/#findComment-81947
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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