[SOLVED] Problem with a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

[SOLVED] Problem with a function

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

oh :)

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

anyway thx again

[SOLVED]
Post Reply