Solved

puting echo into a variable

Posted on 2011-03-05
2
276 Views
Last Modified: 2012-05-11
learning php :)
this is probably really easy to do but am stuck and running out of coffee
i currently have this block of code :

if ($name==$dbusername&&$password==$dbpassword)
      {
            
      
      $_SESSION['UserName']=$name;
      if ($_SESSION['UserName'])
echo "Welcome to the scapp gaming network, ".$_SESSION['UserName'];
      
      
      }
      else
      echo "password incorrect!";
}


i would like to position my echos on the page. it currently outputs the echo to the top of the page
and moves the navigation down
how can i echo this where i want it?
thx
0
Comment
Question by:helpchrisplz
  • 2
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35042583
You just put this into the place where you want:
<?php
 if ($_SESSION['UserName'])
echo "Welcome to the scapp gaming network, ".$_SESSION['UserName'];
?>
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35042611
And   if ($_SESSION['UserName']) - this should be
 if (!empty($_SESSION['UserName'])) - you are checking if the SESSION array has the UserName variable set.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now