<?php

$context = array();
$context['theme'] = get_template_directory_uri();
if ($_POST) {
    $phone = $_POST['phone'];
    $code = $_POST['code'];
    $password = $_POST['password'];
    $repeatPassword = $_POST['repeatPassword'];
    if (!$phone) {
        $context['phoneError'] = '请输入11位手机号';
    } else if (!$code) {
        $context['codeError'] = '请输入验证码';
    } else if (!$password) {
        $context['passwordError'] = '请输入新密码';
    } else if (!$repeatPassword) {
        $context['repeatPasswordError'] = '请输入确认密码';
    } else {
        $user = get_user_by('login', $phone);
        if ($user) {
            wp_set_password($password, $user->data->ID);
            echo '成功修改密码';
        } else {
            $context['phoneError'] = '请输入有效的手机号';
        }
    }
}
Timber::render('forget.html', $context);

?>