function EditUserData($idToEdit, $newName, $newEmail, $newPassword, $thenLogin = true)
{
    $link = Connect();
    $sql = "UPDATE `users` SET `name` = '{$newName}', `email` = '{$newEmail}', `password` = '{$newPassword}' WHERE `id` = '{$idToEdit}';";
    mysqli_query($link, $sql);
    echo mysql_error();
    if ($thenLogin) {
        AttemptLogin($newName, $newPassword);
    }
    Email($newEmail, "*****@*****.**", "DnD Account", "Your info has been edited! Your new name is: " . $newName . ", your password is: " . $newPassword . ". Check all other stuff online on http://www.timfalken.com/dnd/");
}
Example #2
0
?>

<?php 
$username = "";
if (isset($_POST['submit'])) {
    $fields_required = array("username", "password");
    ValidatePresence($fields_required);
    $fields_with_max_lengths = array("username" => 40);
    ValidateMaxLengths($fields_with_max_lengths);
    $fields_with_max_lengths = array("username" => 40);
    ValidateMaxLengths($fields_with_max_lengths);
    if (empty($errors)) {
        //Login
        $username = $_POST["username"];
        $password = $_POST["password"];
        $found_admin = AttemptLogin($username, $password);
        if ($found_admin) {
            $_SESSION['admin_id'] = $found_admin["id"];
            $_SESSION['username'] = $found_admin["username"];
            RedirectTo("admin.php");
        } else {
            $_SESSION["message"] = "Username/Password not found.";
        }
    }
} else {
}
?>

<?php 
$context = "admin";
include "../includes/layouts/admin-header.php";