vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Custom Login (https://vborg.vbsupport.ru/showthread.php?t=147923)

HuggyCT2 05-23-2007 01:30 PM

Custom Login
 
Hey guys,

Well I am making a seperate cms for my site www.clantemplates2.com

Now what I want to do is make a login script for the admin panel on the cms. I have coded many login scripts before but this just wont work and I cant see why.

Heres the code.

PHP Code:

<div id="staff1">
<?php
/*
www.clantemplates2.com
CT2 Custom cms
Coding by Supernal and Huggy
*/

// staff login for the cms

    
if (!$_SESSION['ct2_logged'])
        {
            if (!
$_POST['login'])
                {
?>
<h3>CT2 Staff Login - ACP</h3>
<h5>Please Login</h5>
<form action="" name="login" method="post">
<p>Username: <input type="text" name="username" class="forms"/></p>
<p>Password: <input type="password" name="password" class="forms"/></p>
<p><input type="submit" name="login" value="Login to Staff" class="forms"/></p>
</form>
<?php
}else{
    if(
$_POST['login'])
        {
        
$username addslashes(strip_tags($_POST['username']));
        
$password md5(md5(addslashes($_POST['password'])));
        
        if (!
$password || !$username)
            {
            echo 
"<div class='error'>Please enter a username and password</div>";
        }else{
            
$query "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
            
$result mysql_query($query) or die (mysql_error());
            
$row = @mysql_fetch_array($result);
            
            
$rank $row['usergroupid'];
            
            if (
$rank == 2)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 4)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 1)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 3)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            if (
$rank == 8)
                {
                echo 
"<div class='error'>Your rank does not support access to the CT2 ACP<br />This has been logged</div>";
                echo 
"<meta http-equiv='refresh' content='0; url=index.php?page=login'>";
                exit;
            }
            
            if (
$row)
                {
                
$_SESSION['ct2_logged'] = $username;
                echo 
"<div class='error'>Loggin into CT2 staff ACP<br />
                <a href='index.php?page=admin'>Click here if you are not auto redirected</a></div>
                <meta http-equiv='refresh' content='3; url=index.php?page=admin'>
                <img src='images/loading.gif' alt='Loading' title='Loading'/>"
;
            }else{
                echo 
"<div class='error'>Wrong username or password</div>";
                echo 
"<meta http-equiv='refresh' content='2; url=index.php?page=login'>";
                }
            }
        }
    }
}
if (
$_SESSION['ct2_logged'])
    {
?>
Logged in as <?php echo $_SESSION['ct2_logged']; ?><br />
<a href="index.php?page=admin">Go to ACP</a> or <a href="index.php?page=login&amp;action=logout">Logout</a>
<?php
if ($_GET['action'] == "logout")
    {
    
session_start();
    
session_destroy();
    echo 
"Logging out......<br />";
    echo 
"<img src='images/loading.gif' alt='Loading' title='Loading'/>";
    echo 
"<meta http-equiv='refresh' content='3; url=index.php?page=login'>";
    }
}
?>
</div>

It just wont login, and I cannot figure out why, does anyone know of anything I should be doing different?

byon 05-24-2007 02:44 AM

Quote:

Originally Posted by HuggyCT2 (Post 1253245)

It just wont login, and I cannot figure out why, does anyone know of anything I should be doing different?


You've forgotten the salt under,
PHP Code:

$password md5(md5(addslashes($_POST['password']))); 

check out the vbulletin articles at the navbar ontop. lots of tutorials there. :P


All times are GMT. The time now is 03:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01125 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete