News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Exit

Started by Tomer, September 16, 2004, 04:37:23 PM

Previous topic - Next topic

Tomer

Untill know, whenever I have a script, and lets say a user inputs a wrong password or something, I give him an error message, and than exit();

But this is bringing many problems, as I use two templates (above and below) so when I exit, it destroys any ending tables I have coming.

Any simple way around this?

Shoeb Omar

depends how you have your templating set up - Using SMF?

Tomer

Its not connected with SMF, I have 2 main functions, template_above, and below.

Parham

i know this'll sound stupid.. but why won't you remove one of them?

Shoeb Omar

I know this'll sound more stupid but why don't you do

template_below();
exit();

Parham

Quote from: Shoeb Omar on September 16, 2004, 09:12:41 PM
I know this'll sound more stupid but why don't you do

template_below();
exit();

you were right.. that did sound stupid LOL :P ;) jk jk
that's what I meant... the template function itself doesn't need the exit function.

Tomer

No, not sure you understand. I write every page like this:


<?php

require("templates.php");

template_above(); //everything before the page content [header...menu...etc]

echo "This is the downloads page.";

if (
1)
exit; 
// see now the tempale below will be exited, so the copyright wont be shown

template_below(); // everything after the page content [copyright...etc]


?>


Grudge

I don't understand, why exit at all?? Why not:


if ($password = 'correct')
  show_logged_in();
else
  show_error();


I'd personally have a function to exit the program with, which checks whether the footer has been sent and if not calls it accordingly. Then have a error function to call in case of error which basically shows the error and calls the execution stopping program which sticks on the footer. Hope this makes sense...
I'm only a half geek really...

Tomer

Grudge, I know I can do everything with if, but I have a lot of things to check, just wanted to make sure there wasn't a function I was overlooking.

Grudge

OK, I'm still not entirely sure what the problem is but what about this?


<?php

require("templates.php");

template_above(); //everything before the page content [header...menu...etc]

login();

template_below(); // everything after the page content [copyright...etc]

function login()
{
echo 
"This is the downloads page.";

if (
1)
return; 
// see now the tempale below will be exited, so the copyright wont be shown

// Other stuff here...
}

?>

I'm only a half geek really...

Parham

what you're doing it sort of weird... if your if statement outputs html and stuff... then leave it where it is... otherwise just move it down after the template_below() function.  in any case you generally don't want to exit there, what you want to do is more like what Grudge pointed out.

i use ... A LOT!!!

roboter88

I dont understand what is so good with a up and down template?
IN SMF theme default ...their are 2 functions 1 for the header and 1 for the footer...

I mean why dont change the template liek seen in SMF theme index.template.php  instead?

And what about calling a url - redirecting to some error page - instead of the exit(); ?

Elissen

Can't you add a function to templates.php:
<?php
function texit() {
    template_below();
    exit();
}
?>


and call texit(); instead of exit():?

Tomer

Sorry I guess I didnt explain good enough, thats not what I meant...

But thanks anways. :)

Elissen

I think I think were your heading now. Functions like compareInput($somevar, ''), inputSet(), equalTo() ect? (left the params out on purpose)

Advertisement: