Solved

puting echo into a variable

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exporting image to excel from php document 10 28
Crazy text will not be removed no matter what I try! 13 30
error log using ftp 7 41
How would I do this...? 2 28
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

778 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