Page 1 of 1

[SOLVED] Problem with a function

Posted: Sat Aug 14, 2004 9:40 am
by Getran
Hey, i made a function to check if the user is logged in (justa a simple one)

this is it:

Code: Select all

<?php
function checkLogin() {
// Check if the the terrastormlogin exists:
    if (isset($_COOKIE['terrastormlogin']))
    {
      return true;
		}
    else if (!isset($_COOKIE['terrastormlogin']))
    {
      return false;
    }
}
?>
and then on my page i have this:

Code: Select all

<?php
require("functions.php");
if (checkLogin() == true)
{
  $logpic = "nav_03_out.jpg";
  $loglink = "logout.php";
}
else
{
  $logpic = "nav_03.jpg";
  $loglink = "login.php";
}
?>
But i keep getting this error:

Fatal error: Cannot redeclare checklogin() (previously declared in *hidden*\functions.php:7) in *hidden*\functions.php on line 5

Posted: Sat Aug 14, 2004 9:45 am
by markl999
require("functions.php");

You're probably requiring/including functions.php elsewhere too. Just replace require or include with require_once or include_once

Posted: Sat Aug 14, 2004 9:49 am
by Getran
oh :)

i hate it when i don't notice things like that :/

anyway thx again

[SOLVED]