envexlabs Posted June 25, 2007 Share Posted June 25, 2007 Hey, in my index.php i have included a functions.php file. my index.php has: <?php display_login(); display_nav(); ?> the functions in functions.php function display_login(){ echo('<div id="login" style="display: none;"> <form method="post" action="../amember/login.php"> <p>User Name: <input class="login" type="text" name="amember_login" /> Password: <input class="login" type="password" name="amember_pass" /> <input type="image" style="height: 38px; width: 38px; vertical-align: bottom;" src="images/go.gif" alt="go" title="Go!" /> <input type="checkbox" name="remember_login" value="1"> <span class="small">Remember me</span></p> </form> </div> <!-- login div --> <div id="welcome">'); if ($au=$_SESSION['_amember_user']){ // user is logged-in print "<p>Hello $au[name_f] $au[name_l]!</p><br>"; print "<a href='../amember/logout.php'>Logout</a>"; } else { // user is not logged-in print '<p>Hello!</p> <a href="javascript:login_fade();">Login</a>'; } echo('</div> <!-- welcome div -->'); } function display_nav(){ global $au; $nav_display = mysql_query('SELECT * FROM `amember_payments` WHERE `member_id` = "' . $au[member_id] . '"'); $nav = mysql_fetch_row($nav_display); //renders out the navigation depending on the user if($nav[2] == 1) { //user user_nav(); } elseif($nav[2] == 2 || $nav[2] == 3) { //store store_nav(); } else{ //guest guest_nav(); } } if i include JUST THE CODE from display_login() in my index.php, the navigation displays properly. If i try and use the function, it only displays the guest nav. $nav isn't being recognized when i use the function, thus display the else, which is guest_nav(); I seem to be having alot of problems with these functions, which has been helped here, so sorry for all the posts Any help is appreciated! Link to comment https://forums.phpfreaks.com/topic/57105-solved-login-nav-functions-not-working/ Share on other sites More sharing options...
per1os Posted June 25, 2007 Share Posted June 25, 2007 You need session_start() at the top of the index.php page if you are using session variables. $au needs to also be global in the display_login function. Link to comment https://forums.phpfreaks.com/topic/57105-solved-login-nav-functions-not-working/#findComment-282159 Share on other sites More sharing options...
envexlabs Posted June 25, 2007 Author Share Posted June 25, 2007 hey, the session has been started in the index page, but i didn't know $au had to be defined global in each function, i will test it out. thanks! Link to comment https://forums.phpfreaks.com/topic/57105-solved-login-nav-functions-not-working/#findComment-282161 Share on other sites More sharing options...
envexlabs Posted June 25, 2007 Author Share Posted June 25, 2007 worked like a charm. thanks again. Link to comment https://forums.phpfreaks.com/topic/57105-solved-login-nav-functions-not-working/#findComment-282163 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.