Community discussions

MikroTik App
 
NatwanTilembar
just joined
Topic Author
Posts: 2
Joined: Fri Oct 07, 2022 9:07 am

api for php IP Bindings

Tue Jan 03, 2023 6:35 am

i have this code

<?php
require('routeros_api.class.php');
include 'include/global.php';
include 'include/function.php';

$username = $_GET['user'];

$sql = "SELECT user_macaddress FROM demo_user WHERE user_name='".$username."'";
$result1 = mysql_query($sql);
$mac = mysql_fetch_array($result1);

$API = new RouterosAPI();

$API->debug = true;

if ($API->connect('192.168.88.1', 'admin', '1')) {

$API->write('/ip/hotspot/ip-binding/add',false);
$API->write('=type=bypassed',false);
$API->write("=mac-address='".$mac."'",true);
$READ = $API->read();
$API->disconnect();
ob_clean();
header("location:http://google.com");

}


?>
i use the php api for mikrotik for add the mac address automatically, but the mac address never shown in my ip bindings in winbox. can u guys help me with this?

Who is online

Users browsing this forum: No registered users and 10 guests