Sindbad~EG File Manager

Current Path : /home/beeson/public_html/WebMathXpert/Demos/
Upload File :
Current File : //home/beeson/public_html/WebMathXpert/Demos/Authenticate.js

function Authenticate(e) {
	var username =  'beeson';
	var password =  'Turing2024';

	if (!username || !password) {
		return;   // do nothing, password protection is not being used.
	}
	
    e.preventDefault(); // Prevent the default form submission

    // Collect form data
    var formData = new FormData(myform);

    // Convert form data to URL-encoded string
    var formParams = new URLSearchParams(formData).toString();

    // Basic Auth credentials
	 var headers = new Headers();
	 headers.set('Authorization', 'Basic ' + btoa(username + ':' + password));
	 headers.set('Content-Type', 'application/x-www-form-urlencoded');

	 // Send POST request with authentication
	 fetch(nextpage, {
        method: 'POST',
        headers: headers,
        body: formParams
    })
    .then(response => {
        if (response.ok) {
            return response.text();
        } else {
            throw new Error('Network response was not ok: ' + response.statusText);
        }
    })
    .then(data => {
        // Handle the response data
        document.open();
        document.write(data);
        document.close();
    })
    .catch(error => {
        console.error('There was a problem with the fetch operation:', error);
    })
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists