page building issue

They have: 461 posts

Joined: Jul 2003

the page building function of a page i'm working on is not building the page correctly. for some reason the heredoc gets placed last, no matter what i do. i've head them all in the else, i've had them as their own seperate variables that i combine at the end then echo, yet in all instances i get the same result, the functions followed by the heredoc of the page below.

<?php
//control.php

# this is the control page. the page that allows the user tomake new pages, delete old pages, etc
session_start(); # sessions call to enable sessions
session_register('dbuser'); # make sure the db user is in the session on this page
session_register('dbpw'); # make sure the db pw is in the session on this page
include('/home/joshua/aislin/funcs.php'); # functions
include('/home/joshua/aislin/vars.php'); # universal variables

if(($dbpw!='')&&($dbuser!='')){ # if we're logged in
 
switch($_POST['disp']){ # what page do we display?
 
case 'page': # create a new page/update a pre-existing page/delete a page
   
$page=pgstrt('control-page', $css, $javascript); # start the page
   
$page.=<<<END

END;
    break;
  case
'gallery': # create/modify/delete a gallery/picture
   
$page=pgstrt('control-gallery', $css, $javascript); # start the page
   
$page.=<<<END

END;
    break;
  case
'blog': # create/modify/delete a blog entry or comment
   
$page=pgstrt('control-blog', $css, $javascript); # start the page
   
$page.=<<<END

END;
    break;
  default:
   
$page=pgstrt('control-', $css, $javascript); # start the page
   
$page.=<<<END
    <h1>Which section of your site would you like to manipulate?</h1>
    <form action=\"
{$_SERVER['PHP_SELF']}\" method=\"POST\">
      <p>
        <select id=\"disp\" name=\"disp\">
          <option value=\"page\"></option>
          <option value=\"gallery\"></option>
          <option value=\"blog\"></option>
        </select>
        <br /><input type=\"submit\" value=\"Adjust Selected Section\">
      </p>
      <p>Click <a href=\"saveres.php\" target=\"_blank\">here</a> to save/restore the database.</p>
    </form>
END;
    break;
  }
}else{
# create login page
 
$page=pgstrt('control-login', $css, $javascript); # start the page
 
$page.=<<<END
    <h1>You Need to Login to Access the Control Panels</h1>
    <form action=\"
{$_SERVER['PHP_SELF']}\" method=\"POST\">
      <p>Your Login Username: <input id=\"user\" name=\"user\" type=\"text\">
        <br />Your Password: <input id=\"pw\" name=\"pw\" type=\"password\">
        <br /><input type=\"submit\" value=\"Log Me In\">
      </p>
    </form>
END;
}
$page.=pgnd(); # close the page
echo $page; # give user the page

//funcs.php

# this is a functions file to be included to other pages

function pgstrt($what, $css, $javascript){ # pagestart -- starts a page
 
include('/home/joshua/aislin/vars.php');
  switch(
$what){
  case
'control-login': $title='Control Panel -- Login Page'; break;
  case
'control-page': $title='Control Panel -- Page Editing'; break;
  case
'control-gallery': $title='Control Panel -- Gallery Editing'; break;
  case
'control-blog': $title='Control Panel -- Blog Editing'; break;
  case
'control-': $title='Control Panel -- '; break;
  case
'welcome':
  default:
$title='Welcome to Aislin\'s Corner'; break;
  }
 
$pagehead=<<<END
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
  <head>
$metas
    <title>
$title</title>
    <style type=\"text/css\">
      <!--
$css
      -->
    </style>
    &lt;script type=\"text/javascript\"&gt;
      <!--
$javascript
      -->
    &lt;/script&gt;
  </head>
  <body>
END;

  echo
$pagehead;
}

function
pgnd(){ # pageend -- ends a page
 
include('/home/joshua/aislin/vars.php');
 
$pageclose=<<<END

    <p style=\"font-size:.8em;font-family:arial;text-align:center;text-decoration:none;\">Page coded and copyrighted by Desired Creations LLC</p>
  </body>
</html>
END;
  echo
$pageclose;
}

// vars.php

# variables file -- db section is something that should be PRIVATE.
$metas='    <meta name=\"Author\" content=\"Pages coded by Desired Creations LLC\" />
    <meta name=\"Description\" content=\"Home Pages of Crystal \'Aislin\' Barnard\" />
    <meta name=\"Keywords\" content=\"\" />'
;

# db section. advisable to make this server only readable. not required
$dbname='aislin'; # name of db to connect to
$dbhost='localhost'; # host on which the db is
?>
this is for a friend with some understanding of css/html/javascript that feels she doesn't have a good way of updating her webpages, so this is the beginging of an interface that will allow her to do all that. one page for controlling a blog, one for photo galleries, and one for regular pages. once i have this all set to work with one who has a good knowledge of those, i plan on creating a gui interface for her to create css classes and set the css that way as well as doing the html editing via a gui interface.

before i can set that up i need to make sure the db interface is working, which requires getting the login to work on the pages that will require some security (sessions are being used here to create that)

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

i added some debugging lines:

<?php
}else{ # create login page                                                                                                 
 
$page=pgstrt('control-login', $css, $javascript); # start the page                                                       
echo $page;
echo \
"<h1>end debug 1</h1></body></html>\";
 
$page.=<<<END                                                                                                            
    <h1>You Need to Login to Access the Control Panels</h1>
    <form action=\"
{$_SERVER['PHP_SELF']}\" method=\"POST\">
      <p>Your Login Username: <input id=\"user\" name=\"user\" type=\"text\">
        <br />Your Password: <input id=\"pw\" name=\"pw\" type=\"password\">
        <br /><input type=\"submit\" value=\"Log Me In\">
      </p>
    </form>
END;
echo
$page;
echo \"<h1>end debug 2</h1></body></html>\";
}
?>
and got
Quote:

Control Panel -- Login Page

<script type="text/javascript">

</script>

end debug 1 You Need to Login to Access the Control Panels

Your Login Username:
Your Password:

end debug 2
Page coded and copyrighted by Desired Creations LLC

You Need to Login to Access the Control Panels

Your Login Username:

Your Password:

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

That's just freaky weird.
"I can't explain it. It's unexplicable." (Anyone watch "Monk"?)

Why are you even appending? Why not just echo it out?

echo pgstrt( ... );
echo <<<heredoc
  blah blah blah
heredoc;
'

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.