Datasheet

API PHP package
54
$printRequest->setQuery(
RouterOS\Query::where('email', $_POST['email'])->andWhere('comment', $_POST['phone'])
);
$id = $client->sendSync($printRequest)->getArgument('.id');
if (null === $id) {
$errors[] = 'Email or phone does not match that of any user.';
}
}
if (!isset($_POST['password']) || !isset($_POST['password2'])) {
$errors[] = 'Setting a new password is required.';
}
if (empty($errors)) {
if ($_POST['password'] !== $_POST['password2']) {
$errors[] = 'Passwords do not match.';
} else {
//Here's the fun part - actually changing the password
$setRequest = new RouterOS\Request('/ip hotspot user set');
$client->sendSync($setRequest
->setArgument('password', $_POST['password'])
->setArgument('numbers', $id)
);
//Redirect back to the login page, thus indicating success.
header('Location: http://192.168.0.1/login.html');
}
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Forgot your hotspot password?</title>
<style type="text/css">#errors {background-color:darkred;color:white;}</style>
</head>
<body>
<div>
<h1>You can reset your hotspot password by filling the following form.
You'll be redirected back to the login page once you're done</h1>
<?php if(!empty($errors)) { ?>
<div id="errors"><ul>
<?php foreach ($errors as $error) { ?>
<li><?php echo $error; ?></li>
<?php } ?>
</ul></div>