Quote:
Originally Posted by ap0c
I had to add an else to the final check because the registered template wouldnt show up when it was placed under the registered users check
other than that it works perfectly.
Thanks again.
Now to add the post check, which will be harder since it cant be checked by the usergroupid
|
Actually I updated my code had a spelling error for the variable usergroupid so the error should eval where I had intended it too. If you want to try matching it against the post ipaddress to then you can do.
PHP Code:
if ( $chk = $DB_site->query_first ( "
SELECT userid, usergroupid
FROM user
LEFT JOIN post USING (userid)
WHERE user.ipaddress='$ipaddress' AND post.ipaddress='$ipaddress'" ) ) :
if ( $chk['usergroupid'] == 8 ) :
// banned error here
elseif ( $chk['usergroupid'] == 2 ) :
// already registered error
elseif ( $chk['usergroupid'] == 9 ) :
$DB_site->query ( "UPDATE user SET usergroupid=2 WHERE userid=$chk[userid]" ) ;
// redirect here
endif ;
elseif ( $chk['userid'] ) :
// user exists just hasn't posted or current ipaddress doesn't match the posted one?
if ( $chk['usergroupid'] == 8 ) :
// banned error
elseif ( $chk['usergroupid'] == 2 ) :
// already registered, but haven't posted? error
elseif ( $chk['usergroupid'] == 9 ) :
$DB_site->query ( "UPDATE user SET usergroupid=2 WHERE userid=$chk[userid]" ) ;
// redirect here
endif ;
else :
// failed check perhaps current ipaddres isn't the one they registered with?
// don't know if vb3 updates ipaddress field with each visit so... check to see if user actually exists!
if( !$chk2 = $DB_site->query_first ( "SELECT usergroupid FROM user WHERE userid=$bbuserinfo[userid]" ) ) :
// user isn't registered
// register redirect or need to register error?
else :
// user exists ipaddress field is invalid perhaps update now?
if ( $chk2['usergroupid'] == 2 ) :
// already registered error
elseif ( $chk2['usergroupid'] == 8 ) :
// banned error
elseif ( $chk2['usergroupid'] == 9 ) :
// update from viewed usergroup to one that can post.
$DB_site->query ( "UPDATE user SET usergroupid=2 WHERE userid=$chk[userid]" ) ;
// redirect here
endif ;
endif ;
endif ;
There's alot to think about when using such code, then again I would probably do it an entirely different way. Hope this gives you some ideas.
Cheers,
g-force2k2