user2981166
user2981166

Reputation: 19

PHP will not Echo

I've tried to look into why this isn't echoing but every result the persons trying use php on an html page so this is why I'm here asking.

I have 3 php files, a login file, a global config file, and a theme file. The login page echo's the login script but it connects to the global file. The global file connects to the theme file and the db config file. The theme file is a simple table.

Here's my files

<?
include('../tools/global.php');



switch($_POST[act]){

case "setlogin":
set($login);
break;

case "refresh":
refresh();
break;

case "logout":
lout();
break;

default:
login($mes);
break;
}

function login($mes){


if (isset($_COOKIE["user"])){
$out[body]="<br />
<center>
<table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#BDBDBD'>
<tr bgcolor='##ff80ff'>
<td width='100%' valign='center' align='left' colspan='2' background='#BDBDBD'>
<strong>Login</strong>
</td>
</tr>
<tr bgcolor='#BDBDBD'>
<td width='100%' valign='center' align='left'><center>
<b>You are already logged in! Would you like to <a href='http://www.fivedesignguys.com/dir/panel/login.php?act=refresh&type=logout'>Logout?</a></center></td></tr>
</table>
</center><br /><br /><br /><br />";

}else{

$out[body]="
<br />
<center>
<table width='400' border='0' cellspacing='1' bgcolor='#BDBDBD' cellpadding='1'>
<form method='post'>
<tr bgcolor='$config[altcolor]'>
<td background='#BDBDBD' width='100%' valign='center' align='left' colspan='2'>
<strong>Login</strong>";

It continues but I know it's going to echo me the first option,

Heres the global php file

<?php

include('../theme/default.php');
include('config.php');

?>

and finally the default.php theme file

<table border='0'>
<tr>
<td colspan='2'>
<center>bar</center>
</td>
</tr>
<tr>
<td width='10%'>
hey<br>hey<br>
</td>
<td>
hello
<?php

echo $out[body];
?>

</td>
</tr>
</table>

as you can tell I want it to echo $out[body] but it doesn't want to. Yes all the files are PHP but this is where I'm stuck.

Upvotes: 0

Views: 64

Answers (1)

Alex
Alex

Reputation: 4774

The $out array is not a global, so it can't be read outside the login() function.

You should declare the array as global and read a bit about globals.

Upvotes: 1

Related Questions