Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
627 views
in Q2A Core by
This is the login that I am trying to recreate so I can couple the structure of the website I have already built.

I know there are plugins The issue at hand is that for me it would be easier to rename all my variables in my website since I know where the are located and point them to qa_user table. I want to have another kind of login form so it feels more natural to my website.

Well, this is the code so far....

<?php

require_once './preguntas/qa-include/qa-base.php';

require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'db/users.php';

// HERE I GET THE PASSWORD AND EMAIL THROUGH SOME POSTED VARIABLES

//THIS IS JUST AN EXAMPLE OF COURSE OF WHAT I AM TRYING TO DO

$p= "somepassword";
$e = "someemail@gmail.com";    
$stmt = mysqli_prepare($db_conx, "SELECT userid, passsalt, passcheck FROM qa_users WHERE email=? LIMIT 1");
mysqli_stmt_bind_param($stmt,'s',$e);
if(!mysqli_stmt_execute($stmt)){//devuelve true si no falla y no es exitosa la query
throw new RuntimeException('Fallo en ejecutar la query');
exit();
}
$result = mysqli_stmt_get_result($stmt);
$exist_count = mysqli_num_rows($result);
if($exist_count > 0){
        $row = mysqli_fetch_row($result);
$db_id = $row[0];
$db_salt = $row[1];
$db_check = $row[2];
}
// free variable result
mysqli_free_result($result);
mysqli_stmt_close($stmt);
if(isset($db_salt)){
if(bin2hex($db_check) != qa_db_calc_passcheck($p, $db_salt)){
echo "login_failed here";
            exit();
} else {

// IN HERE I AM TRYING TO RECREATE THE LOGIN SET SESSION VARIABLES AND ALL OTHER VARIABLES  LIKE IN NORMAL LOGIN OF Q2A

qa_set_session_user($db_id, null);
$sessioncode=qa_db_user_rand_sessioncode();
qa_db_user_set($db_id, 'sessioncode', $sessioncode);
qa_db_user_set($db_id, 'sessionsource', null);

// IN HERE I CAN CREATE ALL THE VARIABLES OR THE NEEDED STUFF FOR QUESTION2ANSWER

}
}
    ?>
by
Are you trying to use Q2A's actual login system? In other words are you storing your users in the qa_users table?
by
Yes I will, actually I have a users table with very similar colums, what I will do is I will add the rest to qa_users table,  like date of birth, biography  avatar, name, last name, and some others. To me is easier to change all the variables in my current code since I know pretty well where those are, integrate all the tables, like friend, followers, posts, etc. to Q2A structure and then understand Q2A little by little. Since understanding Q2A will take me a while. But I insist on creating my own login so I can use my form and integrate the social media logins that I already worked on.

Final thing is that I saw the above script works, but funny thing only when I include the variable $_SESSION in the theme that I am working on. Then I can logout etc.But there are many things that I ignore or I donĀ“t understand and those thing make me uncomfortable like how sessioncode helps you to revalidate your user everytime you change pages or refresh.

Please log in or register to answer this question.

...