Moodle

From assela Pathirana
Jump to navigationJump to search
Koninginnedag 2011 DSC 1884.JPG

Changing The Root Password

  • Forgotten the root password. E-mail is not provided when creating the account or no e-mail working.
<?php
include('config.php'); # need to run at the moodle root via web browser!
//////////
$username = 'foo';
$newpassword = 'bar';
/////////
if ($userobj = get_record_select('user', "username='$username'", 'id, password')) {
        $userobj->password = md5($newpassword);
            update_record('user', $userobj);
                echo 'Password changed';
} else {
        echo 'Invalid username';
}

?>