Jump to content

the ELSE in this function dont werk


sakata

Recommended Posts

i wrote this simple function to auth check certain files i wanted if u were logged in... the file is included if u werent it shows u the form to login... now everything works as far as the sql,php even keepin my sessions alive etc... i don't know why but it if your not logged in it wont show the login form... so basicly the else part in this code doesnt seem to work... i think it may have to do w/ structure...

[code]
function auth_sid_include($file = NULL)
{
        $sid2 = session_id();
        $sql = mysql_query(" SELECT * FROM admin WHERE session = '$sid2' ");
        
        while($auth = mysql_fetch_assoc($sql))
        {
              if ( $sid2 = $auth['session'] ) { include_once ''. $file .''; }
              else { ?>

            <h3>Login</h3>
            <form action="?s=form" method="post" >
            <input type="text" name="user" size="15" maxlength="40" value="" id="user"/>
            <input type="password" name="pass" size="15" maxlength="25" id="pass" />
            <input type="hidden" name="autologin" value="1" />
            <input type="hidden" name="sid" value="<? echo session_id(); ?>" />
            <input type="submit"  name="login" value="submit" />
            </form>
            
            <? }
        }
}
[/code]

thanks in advance for any help...

dan

Link to comment
Share on other sites

I think the problem is here

[code]              if ( $sid2 = $auth['session'] ) { include_once ''. $file .''; }[/code]
Where the $auth array is being defined/passed?

The structure itself is OK I guess (a bit ugly IMO).
Link to comment
Share on other sites

[!--quoteo(post=366297:date=Apr 18 2006, 10:14 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 18 2006, 10:14 PM) [snapback]366297[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I think the problem is here

[code]              if ( $sid2 = $auth['session'] ) { include_once ''. $file .''; }[/code]
Where the $auth array is being defined/passed?

The structure itself is OK I guess (a bit ugly IMO).
[/quote]


uhh... no. that isnt the problem.... and yes the code is sloppy i just wrote it... not really thinking about it.... anyway... like i said it works... i pull and check if the session id is a match if so... the page is included if not i want the form echo`d.... the else part dont work.... oh hmmm i think maybe i found where...

[code]              if ( $sid2 = $auth['session'] ) { include_once ''. $file .''; }[/code]

instead

[code]              if ( $sid2 == $auth['session'] ) { include_once ''. $file .''; }[/code]

ill go give it a try... =/
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.