So I thought I had my registration and user details forms all working - But I noticed that the username and password are not being updated when I change those values on the form and click save? I did a print_r and the queries to save to the tables looks correct.
is there something special I have to do to change username and password? or is the problem just an issue with my code?
here is what the debug on returned (with my print_r):
_POST: Array ( [key_code] => c37518ce7190ddf7000072b9f37821c5 [username] => refstud2 [password] => refstud123 [cpword] => refstud123 [user_email] => [email]reformedstudent@gmail.com[/email] [first_name] => Andrew [last_name] => Adcock [title] => Fellow [vm_hospitalaffiliation] => none [address_1] => 233 Hamel Av [address_2] => [city] => Glenside [state] => [zip] => [undefined] => Save [27c6d142b7d71304b4bb1bfd6bc7dae9] => 1 )
Your License key is = 3f4a67ed75333603000072c87f3ed85f
UPDATE `#__users` SET `username` = 'refstud2', `password` = 'refstud123' WHERE `user_id` = (236) ;
and here is the save code when the username or password is modified:
<?php
global $row_jos_vm_user_info;
$user =& JFactory::getUser();
echo '<div class="key_page">';
$smuser = $user->id;
if($user->username != $_POST['username'] || $_POST['password']){
$strLogin = $_POST['username'];
if($_POST['password']){
$strPassword = $_POST['password'];
/* some key creation code here */
echo '<br/><br /><h3><b>Your License key is</b> = '.$key.'</h3></div>';
/* now save the new data */
$db =& JFactory::getDBO();
$query = '
UPDATE `#__vm_product_license`
SET `license_start` = "'.time().'", `key_code` = '.$key.'
WHERE `user_id` = '.$smuser.';';
$db->setQuery($query);
$db->query();
//echo print_r($query, true);
// now the second update
$q = '
UPDATE `#__users`
SET `username` = "'.$strLogin .'", `password` = "'.$strPassword .'"
WHERE `user_id` = '.$smuser.'';
$db->setQuery($q);
$db->query();
echo print_r($q, true);
}else{
echo '<br/><br />
<h3><b>You must set a new password if you wish to change the username! <br />
No, new license was created.</b></h3>';
}
}else{
// code if username and password were unchanged
?>
if the print_r's return a query that works perfectly in mysql - why is the UPDATE not happening??