Jump to content

Undefined function.


unsider

Recommended Posts

<?php
if (!isLoggedIn())
{

    if (isset($_POST['cmdlogin']))
    {
      
        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_userbox();
        } else
        {
            echo "Incorrect Login information !";
            show_loginform();
        }
    } else
    {

        show_loginform();
    }

} else
{

    show_userbox();
}
?>

 

Fatal error: Call to undefined function isLoggedIn() in ..website name.. on line 2

Link to comment
https://forums.phpfreaks.com/topic/92194-undefined-function/
Share on other sites

Read the message:

Fatal error: Call to undefined function isLoggedIn() in ..website name.. on line 2

 

Notice the important parts:

Fatal error: Call to undefined function isLoggedIn() in ..website name.. on line 2

 

Look at your line 2:

if (!isLoggedIn())

 

Now show me where in your code you defined that function.  i.e. where in your code do you have this:

function isLoggedIn(){
  // does something
}

Link to comment
https://forums.phpfreaks.com/topic/92194-undefined-function/#findComment-472275
Share on other sites

<?php

include ("db_connect.inc.php");



if ( $_GET["op"] == "reg" )      ---------------------------11
{
$bInputFlag = false;
foreach ( $_POST as $field )
	{
	if ($field == "")
   {
   $bInputFlag = false;
   }
	else
   {
   $bInputFlag = true;
   }
	}

if ($bInputFlag == false)
	{
	die( "Problem with your registration info. "
   ."Please go back and try again.");
	}


$q = "INSERT INTO `members` (`username`,`password`,`email`) "
	."VALUES ('".$_POST["username"]."', "
	."PASSWORD('".$_POST["password"]."'), "
	."'".$_POST["email"]."')";

$r = mysql_query($q);


if ( !mysql_insert_id() )
	{
	die("Error: User not added to database.");
	}
else
	{

	Header("Location: register.php?op=thanks");
	}
} 



elseif ( $_GET["op"] == "thanks" )                ------------------------------- 55
{
echo "<h2>Thanks for registering!</h2>";
}


else
{
echo "<form action=\"?op=reg\" method=\"POST\">\n";
echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
echo "<input type=\"submit\">\n";
echo "</form>\n";
}
// EOF
?>

 

Notice: Undefined index: op in ..website.. on line 11

 

Notice: Undefined index: op in ..website.. on line 55

 

Marked #s

Link to comment
https://forums.phpfreaks.com/topic/92194-undefined-function/#findComment-472331
Share on other sites

Add this at the top:

$op = isset($_GET['op']) ? $_GET['op'] : '';

 

Then everywhere in your code where you have $_GET['op'], use $op instead.

 

The error is saying the index is not defined, or that $_GET has no index named 'op' associated with it.  The line you put at the top of the script will set $op equal to $_GET['op'] if the index is set and the empty string if it is NOT set.

Link to comment
https://forums.phpfreaks.com/topic/92194-undefined-function/#findComment-472338
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.