Hey all,
Been trying to work this out. But I'm stumped!
Got a database running on Moodle. Want to create an external script which uses the usernames and passwords from the table moodle_user and the db Profiled_Moodle.
Here is my page so far:
<?php include 'header/config.php';?>
<div id="Container">
<?php
if ($_POST['submit']) {
//your dbname
mysqli_select_db($con,'moodle_user') or die(mysql_error());
$salt = '7(}AouN0sysQF#{]s@[F]Y~b]5E'; //change with your salt
$password = md5($_POST['password'] . $salt);
$username = $_POST['username'];
$query = "SELECT * FROM moodle_user WHERE username = '{$_POST['username']}' AND password = '$password'";
$result = mysql_query($query) or die(mysql_error());
echo '<pre>' . $username ;
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
echo 'logged in as:' . $username;
}
} else {
echo "Not logged in";
}
?>
The reason I have that salt is because in moodle config.php I have that set.
$CFG->passwordsaltmain = '7(}AouN0sysQF#{]s@[F]Y~b]5E';
When I login to the form. Nothing is happening? I'm not getting an echo or print
Thanks guys