Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    42
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Check if account is activated

    Hi,
    I'm having a little problem checking to see if a account has been activated or not. I don't know if i'm on the right track or not, here is what i got and what im trying to add. First is my login script, and second is what im trying to add to check if the account has been activated. Any help would be great thanks.

    Login script:
    PHP Code:
    session_start();
    include_once(
    "db.php");
    $errors = array();
    if(isset(
    $_POST["iebugaround"])){
        
    $uname trim(htmlentities($_POST['username']));
        
    $passw trim(htmlentities($_POST['password']));
        if (empty (
    $uname) || empty ($passw)) {
            
    $errors[] = "$required_fields";
        }
        if(!
    $errors){
            
    $passencrypt hash('sha512'$_POST['password']);
            
    $query "SELECT * FROM members WHERE username='".mysql_real_escape_string($uname)."' AND password='".mysql_real_escape_string($passencrypt)."'";
            
    $result mysql_query($query) OR die(mysql_error());
            
    $result_num mysql_num_rows($result);
            if(
    $result_num 0){
                while(
    $row mysql_fetch_array($result)){
                    
    $idsess stripslashes($row["id"]);
                    
    $username stripslashes($row["username"]);
                    
    $_SESSION["SESS_USERID"] = $idsess;
                    
    $_SESSION["SESS_USERNAME"] = $username;
                    
    setcookie("userloggedin"$username);
                    
    setcookie("userloggedin"$usernametime()+43200);
                    
    header("Location: users-area.php");
                    exit();
                }
                } else {
                
    $errors[] = "$incorrectLogin";
            }
        }

    Code trying to add:
    PHP Code:
    if ($row["actnum"] == "0"){
    //Then login to site
    }else{
    $errors[] = "$accountNotActivated";


  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    try:

    PHP Code:
    <?php
    session_start
    ();
    include_once(
    "db.php");
    $errors = array();
    if(isset(
    $_POST["iebugaround"])){
        
    $uname mysql_real_escape_string(trim(htmlentities($_POST['username'])));
        
    $passw mysql_real_escape_string(trim(htmlentities($_POST['password'])));
        if (empty (
    $uname) || empty ($passw)) {
            
    $errors[] = "$required_fields";
        }else{
        
    $passencrypt hash('sha512'$_POST['password']);
        
    $query "SELECT * FROM members WHERE username='".$uname."' AND password='".$passencrypt."'";
        
    $result mysql_query($query) OR die(mysql_error());
        
    $result_num mysql_num_rows($result);
        }
        if (
    $row["actnum"] == "0"){
            
    //Then login to site
        
    }else{
            
    $errors[] = "$accountNotActivated";
        } 
            
        if(!
    $errors){
            if(
    $result_num 0){
                while(
    $row mysql_fetch_array($result)){
                    
    $idsess stripslashes($row["id"]);
                    
    $username stripslashes($row["username"]);
                    
    $_SESSION["SESS_USERID"] = $idsess;
                    
    $_SESSION["SESS_USERNAME"] = $username;
                    
    setcookie("userloggedin"$username);
                    
    setcookie("userloggedin"$usernametime()+43200);
                    
    header("Location: users-area.php");
                    exit();
                }
            } else {
                
    $errors[] = "$incorrectLogin";
            }
        }
    }  
    ?>

  • Users who have thanked Arcticwarrio for this post:

    ycpc55 (07-31-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •