Guest WiFi Access Portal

Guest WiFi Access Portal

Please fill all required fields.
"; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { // Validate email echo "
Invalid email format.
"; } elseif (!preg_match("/^[0-9]{10,15}$/", $phone)) { // Validate phone number (only digits and length between 10-15) echo "
Invalid phone number. Please enter a valid number with 10 to 15 digits.
"; } else { // Get MAC address automatically (for demonstration purposes, using a sample MAC address) $mac = "00:11:22:33:44:55"; // Login to UniFi Controller $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$controllerUrl/api/login"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["username" => $username, "password" => $password])); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); if (!$response) { echo "
Error: Unable to login to controller.
"; } else { // Authorize Guest $minutes = 60; // Duration of access in minutes curl_setopt($ch, CURLOPT_URL, "$controllerUrl/api/s/$site/cmd/stamgr"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["cmd" => "authorize-guest", "mac" => $mac, "minutes" => $minutes])); $response = curl_exec($ch); curl_close($ch); if ($response) { echo "
Guest authorized successfully. Enjoy your WiFi!
"; } else { echo "
Error: Unable to authorize guest.
"; } } } } else { // Display the guest login form echo '
'; } ?>