User creation and activation

Discussion in 'Joomla' started by ByteCoder, Aug 18, 2010.

  1. #1
    Hello,
    I've made my own user creation (since I want people to be able to register only from a certain redirection)
    But I dont seem to be able to activate the user!
    I get E_NOLOGIN_ACCESS error when trying to login with the username and password.
    I'd see the user in the DB. Heres the code I'm using :

    //generate user and pass
    $user = mt_rand(1, 99999999);
    $salt = mt_rand(10300678912300008000045670002345, 99999999999999999999999999999999);
    $salt = md5($salt);
    $password_real = mt_rand(1000, 999999);
    
    $password = md5($password_real . $salt) . ':' . $salt;
    
    //db info
    $db_hostname = 'db.domain.com'; //Server where MySQL is running. 
    $dbName = 'dbName'; // the name of the db including all the users
    $db_user = 'dbUsername'; //Username to connect with. 
    $db_pass = 'dbPassword'; //Password to connect with. 
    $usersTable = 'jos_users'; //the table where we have the users' info
    $DateOfRequest = date("Y-m-d H:i:s", strtotime($_REQUEST["DateOfRequest"]));
    
    //make connection
    $mysql_con = mysql_connect($db_hostname,$db_user,$db_pass) or die("Unable to connect to the SQL server..."); 
    $mysql_db = mysql_select_db($dbName, $mysql_con);
    
    //register user
    $sqlq = "INSERT INTO " . $usersTable . " (name, username, email, password, usertype, block, sendemail, gid, registerdate, lastvisitdate, activation, params) values ('". mysql_real_escape_string($user) . "','" . mysql_real_escape_string($user) . "','". mysql_real_escape_string($user) . "','" . mysql_real_escape_string($password)  ."', 'Registered' , '0', '1', '18', '".$DateOfRequest."', '".$DateOfRequest."', '', '')";
    mysql_query($sqlq);
    
    
    echo "<script language='javascript'>alert('Thank you for registering! Username : ' . $user . ', Password : ' . $password_real . ''');</script>";
    Code (markup):
    Any ideas? Any suggestions? Improvements? :)
     
    ByteCoder, Aug 18, 2010 IP
  2. mgold

    mgold Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    wow that looks very complex!
     
    mgold, Aug 26, 2010 IP
  3. gamechanger

    gamechanger Active Member

    Messages:
    244
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    50
    #3
    why do it this way? Joomla is not known for being flexible in this area.
     
    gamechanger, Aug 29, 2010 IP