Forums

How to execute two queries in one statement Joomla

hmdadou 22 Jan, 2013
I've created joomla registration form works fine then I added a query to copy the results into another table called users the only problem i am having is the password ...I didn't want to copy the password because is hashed by joomla i added my own script to hash the password.
basically the script works only with one query at a time.
here's the code

$getpassword = JRequest::getString('password', '', 'post');
$salt = substr(md5($password), 0, 2);
$password = md5($salt . $getpassword ) . ':' . $salt;


$db = &JFactory::getDBO();
    $query = "INSERT INTO users (id,name,email)
    SELECT #_users.id, #_users.name, #_users.email
    FROM #_users ORDER BY ID DESC LIMIT 1"; 
    $db->setQuery($query);
    $db->query();


here is the other query i've tried everything to include it inside the above script never worked.
INSERT INTO users (password) VALUES($password)


Any ideas to combine these two?

Much appreciated
GreyHead 22 Jan, 2013
Hi hmdadou,

Just curious, why do you need to save the password hash in another table? There are very few good reasons to do this (or any other duplicated user data either). If you find the Joomla! code that does this in the com_users component, or the version in the ChronoForms Joomla! Registration action then you should be able to adapt it for this task.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger