SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Location
    Web
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with Fatal error: Call to undefined function logged_in()

    Hello all, I am getting the above error while I was trying to make a login system.

    These are my codes.

    HTML Code:
            
    		<!-- Website Navigation Bar placed here -->
    	
    		<div class="container">
    			<div class="navbar navbar-inverse">
    				<div class="navbar-inner">
    					<div class="container" style="width: auto">       
    						<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
    							<span class="icon-bar"></span>
    							<span class="icon-bar"></span>
    							<span class="icon-bar"></span>
    						</a>
    						<div class="nav-collapse collapse">
    						<ul class="nav">
    							<li><a href="http://ankursinha.net/tofsis/index.php"><strong>Home</strong></a></li>
    							<li><a href="http://ankursinha.net/tofsis/index.php"><strong>Downloads</strong></a></li>
    						</ul> 
    <?php 
    	if(logged_in() === true) 
    	{
    		include $_SERVER["DOCUMENT_ROOT"].'/tofsis/faculty_logged_in.php';
    	} 
    	else 
    	{
    		include $_SERVER["DOCUMENT_ROOT"].'/tofsis/logged_out.php'; 
    	}
    ?>					
    Based on whether the person is logged in or not, the dropdown changes. Those codes are below.

    If logged in:

    HTML Code:
    							<ul class="nav pull-right" role="navigation">
    		    					<li class="dropdown">
    		    						<a href="#" id="link1" role="button" class="dropdown-toggle" data-toggle="dropdown">
    		    							<strong>Hi, <?php echo $user_data['faculty_fname']; ?></strong>
    		    							<b class="caret"></b>
    		    						</a>
    		    						<ul class="dropdown-menu" role="menu">
    		    							<li><a href="changepass.php">Change Password</a></li>
    		    							<li><a href="logout.php">Log Out</a></li>
    		    						</ul>
    		    					</li>
    							</ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    If not logged in:

    HTML Code:
    							<ul class="nav pull-right" role="navigation">
    		    					<li class="dropdown">
    		    						<a href="#" id="link1" role="button" class="dropdown-toggle" data-toggle="dropdown">
    		    							<strong>Hi, <?php echo $user_data['faculty_fname']; ?></strong>
    		    							<b class="caret"></b>
    		    						</a>
    		    						<ul class="dropdown-menu" role="menu">
    		    							<li><a href="flogin.php">Faculty Login</a></li>
    		    							<li><a href="slogin.php">Student Login</a></li>
    		    						</ul>
    		    					</li>
    							</ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    And this is my logged in function:

    HTML Code:
    function logged_in() {
    		return (isset($_SESSION['faculty_id'])) ? true : false ;
    	}
    Thing is no matter I am logged in or not, I still get the same error.

    Here is the site link: http://ankursinha.net/tofsis/

    Please help me solve this problem. The code ran perfectly on my localhost having PHP 5.3, but I am facing problem on the webserver having PHP 5.3 though I think the version is not the problem here.

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,032
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    You need to either include or require the file containing the logged_in() function before you can use it
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Location
    Web
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done that bro

  4. #4
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where have you started the session? You should have the code session_start(); at the top of every page that you use it on, otherwise you can't access the session data.
    Even though PHP reads your code for functions before it calls them, its general best programming practice to define the functions above where you call them. Where is the include for this function?

    Also, you mention that your web host has PHP 5.3 installed. Make sure its running that version using the php_info(); function. I know with my experience that some hosts have 5.3 off by default (but have it installed) which you need to enable via an .htaccess file. If this is the case the following .htaccess code should be used in the root directory:

    Code XML:
    #Use PHP 5.3
    AddType application/x-httpd-php53 .php

    With what you have posted it is hard to tell what the issue is. Please post more code in context for further assistance.

    Hope this helps,
    Rick

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Location
    Web
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have started the session on top of init.php page, init.php page requires the connect.php, functions.php

    And I checked with phpinfo(), it shows 5.3 only, nevertheless I will add that code to my .htaccess file.

    And now I am getting this error: Fatal error: Allowed memory size of 65011712 bytes exhausted (tried to allocate 40961 bytes) in /home/ankursvo/public_html/tofsis/init.php on line 2

    Line 2 contains ob_start() and the next line contains session_start()


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •