Solved

puting echo into a variable

Posted on 2011-03-05
2
275 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

706 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

19 Experts available now in Live!

Get 1:1 Help Now