Как пользователи могут выходить из строя/удалить свою учетную запись из базы данных Google разброса, используя JavaScripCSS

Разбираемся в CSS
Ответить Пред. темаСлед. тема
Anonymous
 Как пользователи могут выходить из строя/удалить свою учетную запись из базы данных Google разброса, используя JavaScrip

Сообщение Anonymous »

Привет, ребята, пожалуйста, я застрял в этом коде, нуждаюсь в помощи, поэтому я создал таблицу спреды с названием «Регистр регистрации» и создал 2 таблицы по электронной почте и имени пользователя, а затем вставил код JavaScript в скрипте приложения Google Sheet и развернул его в качестве управляющего авторитета самостоятельно, и рассматривать доступ к доступу, а затем я создал index.html в качестве регистрации. Вместо этого учетная запись их просто будет перенаправлено, и тогда данные не будут удалены из базы данных таблицы листовых таблиц Google, поэтому, пожалуйста, помогите мне исправить этот код, я перечислю весь код, чтобы вы действительно могли на самом деле помочь мне исправить/отлаживать проблему, так что это так, как URL и ключи для таблицы выглядят />https://docs.google.com/spreadsheets/d/ ... edit#gid=0

Общая ссылка https://docs.google.com/spreadsheets/d/ ... ingобразно 4: 32? Am

идентификатор развертывания

akfycbwoq52h_v1hjnzzhv7765ertyuy56ytofxmk8shpjb1wve4uz0v9tw ​​
web app

/>https://script.google.com/macros/s/akfy ... 0v9tw/exec Пожалуйста, обратите внимание, что это не так /> Итак, это код страницы регистрации index.html, который при регистрации они будут перенаправлены на домашнюю страницу < /p>

Код: Выделить всё

    




Registration Form


body {
background-color: #f7f7f7;
}
.container {
margin-top: 50px;
}
#register-box {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.1);
}
#error-message {
margin-top: 10px;
}








Register



Email:


Username:


Register








$(document).ready(function () {
$('#registration-form').submit(function (event) {
event.preventDefault();

var email = $('#email').val();
var username = $('#username').val();

$.ajax({
url: 'https://script.google.com/macros/s/AKfycbwoq52h_V1HJNZ8765678HoT1vWZYaGSObIsSOl7654567HhPJb1wve4UZ0V9Tw/exec',
type: 'POST',
data: {
email: email,
username: username
},
success: function (response) {
if (response === 'Success') {
alert('Registration successful!');
window.location.href = 'home.html'; // Redirect to home page
} else {
$('#error-message').text('Registration failed. Please try again.').removeClass('d-none');
}
},
error: function () {
$('#error-message').text('Registration failed.  Please try again.').removeClass('d-none');
}
});
});
});



< /code>
Таким образом, они перенаправлены, но как только они перейдут на страницу Account.html, которая содержит, что пользователи электронная почта и имя пользователя будут отображаться, и кнопку удаления ниже < /p>
    


User Account


/* Add your custom CSS styles here */
body {
font-family: Arial, sans-serif;
}

.container {
margin-top: 50px;
}

.user-details {
margin-bottom: 20px;
}





User Details

Email: 
Username: 

Delete Account




// Function to fetch user details from the server
function fetchUserDetails() {
$.ajax({
url: 'https://script.google.com/macros/s/AKfycbwoq52h_V1HJNZZhV79876aGSObIsSOl2yTOFXmK8s876e4UZ0V9Tw/exec',
method: 'GET',
success: function (data) {
$('#user-email').text(data.email);
$('#user-username').text(data.username);
},
error: function () {
alert('Error fetching user details');
}
});
}

// Function to delete user account
function deleteUser() {
$.ajax({
url: 'https://script.google.com/macros/s/AKfycbwoq52h_V1H87654ERTUIU7652yTOFXmK8shPJb764UZ0V9Tw/exec',
method: 'POST',
data: {
deleteEmail: $('#user-email').text()
},
success: function () {
alert('Account deleted successfully');
window.location.href = 'index.html'; // Redirect to registration page
},
error: function () {
alert('Error deleting account');
}
});
}

// Fetch user details when the page loads
$(document).ready(function () {
fetchUserDetails();
});

// Attach click event to delete button
$('#delete-btn').click(function () {
deleteUser();
});





Now here is the app script code that runs in google spread sheet app script that allow registration and delete of the data i really dont know which one has the issue so please help me rectify this guys, its really giving me a hard time, here is the appsscript function
< /code>
  function doPost(e) {
var sheet = SpreadsheetApp.openById('1OGHGMH9-Oe8767K-MIxER97p-jNrj987fRv3j_q0Sc').getActiveSheet();

// Check if the request is for registration or deletion
if (e.parameter.hasOwnProperty('email')) {
// Registration request
var email = e.parameter.email;
var username = e.parameter.username;

// Check if the email or username already exists
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
if (data[i][0] == email || data[i][1] == username) {
return ContentService.createTextOutput('User already exists');
}
}

// If the user doesn't exist, append the row
sheet.appendRow([email, username]);

return ContentService.createTextOutput('User registered successfully');
} else if (e.parameter.hasOwnProperty('deleteEmail')) {
// Deletion request
var emailToDelete = e.parameter.deleteEmail;

// Find the row with the email to delete
var data = sheet.getDataRange().getValues();
var rowIndexToDelete = -1;
for (var i = 0; i < data.length;  i++) {
if (data[i][0] == emailToDelete) { // Assuming email is in the first column
rowIndexToDelete = i + 1; // Adding 1 because sheets are 1-indexed
break;
}
}

if (rowIndexToDelete !== -1) {
sheet.deleteRow(rowIndexToDelete); // Delete the row if found
return ContentService.createTextOutput('User details deleted successfully');
} else {
return ContentService.createTextOutput('User not found');
}
} else {
return ContentService.createTextOutput('Invalid request');
}
}
Пожалуйста, кто может помочь мне исправить это, я кодирую его с помощью JavaScript для Cordova App.


Подробнее здесь: https://stackoverflow.com/questions/782 ... base-using
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «CSS»