Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    only want my image to appear when guests are viewing site

    hey guys... got my page with an image and login box... i only whant these to appear if the user is logged in as a "guest" is there sum "what if" statement i can use to get rid of boxes when user is logged in?

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is really too little info.
    how does your user log in?
    where do you store the info(cookie? session?)
    when someone logs in you probably write done some info somewhere,
    check if that info if set, if not, show the pictures.

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    well what happens is when a user loogs in the are sent to the same index page
    i have used
    Code:
    <?
                include("include/adminerr.inc.php");
                if($auth[error]) { include("include/messages/index_unverified.inc.php"); }
                else { include("include/messages/index_verified.inc.php"); } ?>
    so that when a user loggs in it shows a different message

    and here is my login script if it helps

    Code:
    <?
    
    // File ID: login.php (user log in routine)
    
    include("require/config.php");
    require("require/membership.php");
    
    $content="include/loginbox.inc.php";
    $menu="include/menu_u.inc.php";
    $page_title="Login Form";
    
    if ($HTTP_POST_VARS) {
        if ($login && $password) {
    	$password=crypt($password, $login);
    	$data=authenticate($login, $password);
    	if ($data[error]) {$error=$data[error];}
    	else {
    		setcookie("ProfilePHP","$login&&$password", 0, "/");
    		if (!$ref) {$ref="index.php";}
    		Header("Location: redirect.php?ref=$ref");
    	}
      } else {$error="901";}
    }
    
    error_message($error);
    
    include("include/header.inc.php");
    include("include/body.inc.php");
    include("include/footer.inc.php");
    ?>

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I think we need the code for the actual page where the box appears.
    That's where your PHP "if" statement will be.

  • #5
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok heres all i got on it

    Code:
    <table width="100%" summary="body">
      <tr>
        <td width="15%" height="96" align="left" valign="top"><center>
            <?include("include/info.inc.php"); ?>
          </center>
          <?include("$menu");?></td>
        <td width="1%" align="left" valign="top" bgcolor="#FFFFFF"><div id="linedown"> <img src="http://www.runnerselite.com/images/linedown.jpg" alt="linedown" />       
          </div></td>
        <td width="84%" align="left" valign="top"><?
    if (file_exists($content)) {
    include($content);
    } else {?>
          <?echo $content;?>
          </p>
          <?} ?>
        </td>
      </tr>
    </table>
    body used where content and things will apear


    here is the page where its the index.inc.php, so this is where all info for both logged in users and guests appear

    Code:
    <table width="100%" summary="maincontent">
      <tr>
        <td align="left" valign="top" bgcolor="#FFFFFF"><h1 align="left"><img src="../images/runner.jpg" alt="runner" width="127" height="155" align="left"/></h1>
            <h1 align="center"><u> Welcome Back To RunnersElite!</u></h1>
         <center>        
             <?
                include("include/adminerr.inc.php");
                if($auth[error]) { include("include/messages/index_unverified.inc.php"); }
                else { include("include/messages/index_verified.inc.php"); } ?>
          
           <p>&nbsp;</p>
           <p>&nbsp;</p>
           <p>&nbsp; </p>
         </center>
    			
          <center>
            <a href="../register.php"><img align="middle" src="../images/bemem.gif" alt="signup" width="280" height="250" border="0" /></a>
        </center>   </td>
        <td align="left" valign="top"><?include("include/loginbox.inc.php"); ?></td>
      </tr>
    </table>
    and here is the index that hold it all together

    Code:
    <?
    // File ID: index.php (main page for profile site)
    
    
    include("require/config.php");
    require("require/authmember.php");
    
    $auth=authenticate($login, $password);
    include("include/get_config.inc.php");
    $content="include/index.inc.php";
    if ($auth[error]) {$menu="include/menu_u.inc.php";} else {$menu="include/menu_v.inc.php";}
    
    include("include/header.inc.php");
    include("include/body.inc.php");
    //include("include/footer.inc.php");
    ?>

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I think you should look at this line:

    if ($auth[error]) {$menu="include/menu_u.inc.php";} else {$menu="include/menu_v.inc.php";}

    They check for authorization.
    If the user is logged-in, they include the file: menu_v.inc.php
    Otherwise, they include: menu_u.inc.php

    Compare those two files and see what is difference is between them.

    ==========================

    Another thing you might want to try ... but make sure you save a copy
    of your original "index.inc.php" before you overwrite it.

    PHP Code:
    <table width="100%" summary="maincontent">
      <tr>
        <td align="left" valign="top" bgcolor="#FFFFFF"><h1 align="left"><img src="../images/runner.jpg" alt="runner" width="127" height="155" align="left"/></h1>
            <h1 align="center"><u> Welcome Back To RunnersElite!</u></h1>
         <center>        
             <?
                
    include("include/adminerr.inc.php");
                if(
    $auth[error]) { include("include/messages/index_unverified.inc.php"); }
                else { include(
    "include/messages/index_verified.inc.php"); } ?>
          
           <p>&nbsp;</p>
           <p>&nbsp;</p>
           <p>&nbsp; </p>
         </center>
        
    <?    
    if($auth[error]) {
    echo
    "    
          <center>
            <a href='../register.php'><img align='middle' src='../images/bemem.gif' alt='signup' width='280' height='250' border='0' /></a>
        </center>   </td>
        <td align='left' valign='top'>"
    ;
    include(
    "include/loginbox.inc.php");
    echo
    "</td>";
    }
    else{
    echo 
    "<br>\n";
    }
    ?>
      </tr>
    </table>


  •  

    Posting Permissions

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