PDA

View Full Version : Anylink drop-down menu target="" causing problems



Spinethetic
06-11-2008, 08:52 PM
1) Script Title: Anylink dropdown menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

3) Describe problem: http://integralbuddha.net I have installed a PHP/MySQL registration and login system from tutorial (http://www.evolt.org/php_login_script_with_remember_me_feature); and the problem more seems to not necessarily be with the dd menu but rather with this login system which automatically logs users out if a visitor clicks on a link that has attribute target="anyvalue", supposedly because the developer of the php assumes any link with the target attribute MUST be an outgoing link, however the problem persists even when the value is "top".

You can see for yourself by logging in with
username: demo, password: demo. I have fixed the main menu so after logging in click "LINKS" and everything is running smoothly, but mouse over the main blue menu and click a 'drop-downed' link and see what happens.

And I stupidly made every link, even internal, with a target="top" attribute. :mad: I am now in the middle of scouring through two-hundred odd some pages looking for every internal link with the target attribute and removing it. Though in my dropdown.js file I do not have any TARGET attributes though which perplexes me:confused:

Best Regards to a great script a great community
~Ross Vaughn

ddadmin
06-11-2008, 09:03 PM
The logout issue doesn't look like it's related to clicking on any of the links in the drop down menu at all. For example, if I click on the link "Research" -> Sociology, the target page appears to have logged me out. Fine. However, this is the case even if I directly call the target URL in my browser (http://www.integralbuddha.net/research_sociology.htm), bypassing the menu altogether.

Basically it appears the target pages linked to from the drop down menu are themselves not persisting your login info.

Spinethetic
06-11-2008, 09:23 PM
Well, I'am really confused now because in order for each page to detect whether or not a user is logged in I have


<?php
session_start();
include("file_to_connect_to_database.php");
include("login_authentication.php");
?>

At the top of every page, which is supposed to determine whether or not the user is logged in (via php sessions and a cookie for the 'Remember me' aspect to work. I had thought that maybe the problem was something in the dropdown.js file because the site acted like I described above but now, five minutes later, it logs out whenever a new page is loaded, irregardless of whether target="..." is present. In all likelihood this is a php problem so this topic should be moved to the PHP section.

Lord almighty this login/registration thing has been frustrating the *blank* out of me 5-13 hours a day for nearly two weeks now...

I need a ciggerette :P

Best Regards
~Ross Vaughn

Spinethetic
06-11-2008, 09:34 PM
Actually to make a correction I have


<?php $thisPage='somevalue'; $thisSubpage='somevalue'; ?>
<?php
session_start();
include("file_to_connect_to_database.php");
include("login_authentication.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

As the first few lines of every page. Maybe this might be a factor because I always hear about website headers causing problems or something, (I know, you can tell I'am a PHP noobie!)

ddadmin
06-11-2008, 10:19 PM
Without looking at how your login system actually works, it's hard for any outsider that's not familiar with the system to debug this. If you're using a 3rd party CMS, perhaps ask the vendor if they know what the issue could be?

Spinethetic
06-11-2008, 11:08 PM
It is not any sort of CMS, it is slowly evolving into a sort of one but not yet; it is all handcoded

The whole leftside-bar (from the 'login' header down to the clustr-map) is leftside.php (http://integralbuddha.net/leftside.php)
in leftside.php:


<?php
if($logged_in) {
echo '<h3>Hello, '.$_SESSION['username'].'</h3>';
echo '<div class="imgdiv"><font color="#CD2626"><small><u>Notice</u>: blah blah</small></font></div>';
echo '&raquo; <a href="http://integralbuddha.net/logout.php">Logout</a>';
} else {
echo '<h3>Login</h3>';
displayLogin();
}
?>

displayLogin(); displayes the login box, which is in login.php; login.php being included into the header of each and every page:


<?php
session_start();
include("file_to_connect_to_mysql.php");
include("login.php");
?>

login.php can best be explained by the tutorial (http://www.evolt.org/php_login_script_with_remember_me_feature):

It first checks to see if the login form has just been filled out and submitted, if not it checks to see if a session has already been established where the username and password are already known. This is true in two cases, when the user has chosen to be remembered and a session is established automatically, or when the user has not chosen to be remembered but has already logged in and is still using the same browser window that he used to log in.

If either of these two cases is true, then it verifies that the username is in the database and that the password is valid, if these two checks pass then the almighty $logged_in variable is set to true, false otherwise. If the user has just filled out the login form and submitted it, the script detects this and then verifies the authenticity of the username and password, if all is well then session variables are set with the username and md5 encrypted password.

Great, but when does the login form get displayed? That's all up to you. It's up to you the programmer to display the login form when the $logged_in variable is false. But wait! I have added a function that you can call that relieves you of this horrible burden. The displayLogin() function is there to check if the $logged_in variable is true or not and displays information accordingly. How to use this function is described in the Usage section.

Note
login.php is not meant to be a stand-alone file like register.php, it is meant to be included at the top of every file that needs to use it, so it doesn't contain the call to "session_start()", that should be at the top of the file that wants to include login.php, as you will see in the examples below.
orange emphasis: that is what I'am taking advantage of in leftsidebar.php, the leftsidebar.php script is above. If they are logged in, content "A" is visable, if not content "B" is visable; "A" consisting of member tools and "B" consisting of a login form and registration link.

But I don't think the problem is with login.php because I copy-pasted the script for login.php, only modifying the layout and CSS of the form, nothing dangerous. I really can't figure the problem out, registering works like a charm so I know its not a database connection problem, the only thing I could possably think would be that I dident put the PHP snippet in as it should in leftside.php, or maybe login.phpisnt actually supposed to be included in every page. but the reason I did so was that the only things I want different when a user is logged in is for alternate content to appear in the leftsidebar, rather than protecting entire pages.

Best Regards
~Ross Vaughn

Spinethetic
06-12-2008, 12:49 AM
I just came across a PHP error message that may be of interest

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/a8686123/public_html/creativeart_alexgrey.htm:2) in /home/a8686123/public_html/creativeart_andrewgonzalez.htm on line 3

I got this error message when I removed

<?php $thisPage='creativeart'; $thisSubpage='andrewgonzalez'; ?>
from

<?php $thisPage='creativeart'; $thisSubpage='andrewgonzalez'; ?>
<?php
session_start();
include("database.php");
include("login.php");
?>
<!DOCTYPE . . .
The very top of one of my pages, maybe this helps pinpoint the problem, mabe not, but I thought it interesting since I thought the page would survive fine without that first line anyway

And I'am also sure that the login and registration script is using GLOBAL variables, I remember reading comments on a tutorial site saying that they sometimes cause problems...

Spinethetic
06-17-2008, 12:28 PM
Well now after a few brainstorms, how would I add a second level to this menu?

ddadmin
06-17-2008, 08:15 PM
Well now after a few brainstorms, how would I add a second level to this menu?

There's currently no easy way to add additional levels to any of the single level drop down menus on DD unfortunately. The good news is, in the coming weeks, I'll be creating a few that do.