on 14/02/03 10:20 AM, Darren Young ([EMAIL PROTECTED]) wrote:

> That's pretty much what I'm doing today, header page, menu page, content
> page and a footer. Each of which includes a shared functions file as
> well via require_once(). Only real problem is keeping track of
> tables/rows/columns across all the various files. The 'where was that
> <tr> supposed to be...' kind of thing.

yeah, well a complex layout will kill it pretty quick :)

The other way is go down the route of a 'fusebox' -- one script that shows
all pages within the site.

index.php
<?
// some header stuff
?>
<html>
<table>
    <tr>
        <td>Stuff</td>
    </tr>
    <tr>
        <td>
        <?
        $file = "content/{$_GET['p']}.html";
        if(file_exists($file))
            { include($file); }
        else
            { include('content/error.html'); }
        ?>
        </td>
    </tr>
</table>
</html>
    

you can call that script with
p=contact 
p=home
p=about
p=members&action=validate&step=3&favcolor=blue

And just make sure the include files do what they need to.


> Here's another one, there's no way to set a cookie after the headers
> have been sent, true? Any way around this at all or at that point am I
> best to use session variables and/or hidden fields.

Hidden fields, yes.
You are going to have the same problem with sessions... sessions must be set
before the headers are sent too.

You need to either change the logic on your page so that you set the cookie
BEFORE the <html>, or enable output buffering, so that you can set the
cookie or session whenever you like, then do a flush.  Personally, I've
never seen the need to use OB, because I've found a way to work that I'm
comfortable with.

eg:
<?
include('header_code.inc');
if($action=='validate')
    {
    // validate form entry
    if($error)
        { $show_form = 1; }
    else
        {
        $show_form = 0;
        // add form to DB or
        // set a cookie or
        // set a session or
        header("Location: form.php?page=thanks");
        }
    }
?>
<html>
<body>
<?
if($show_form) { include('form.inc'); }
if($_GET['page'] == "thanks") { echo "thanks"; }
?>
</body>
</html>


In otherwords, I execute any code that I need to BEFORE the headers are
sent, to ensure that I CAN set cookies, sessions, or use header()... I set
some simple triggers like $show_form to decide what I want to do in the
body.

Each to their own, but it works great for me over many many applications.


Justin



Justin French


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to