Код HTML страницы:

<!DOCTYPE html>
<html>
<head>
	<title>Отправка SMS</title>
	<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
	<script src="script.js"></script>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
	<form id="sms-form">
		<label for="phone">Номер телефона:</label>
		<input type="text" id="phone" name="phone" required>
		<label for="message">Сообщение:</label>
		<textarea id="message" name="message" required></textarea>
		<label for="count">Количество сообщений:</label>
		<input type="number" id="count" name="count" min="1" max="100" required>
		<button type="submit">Отправить</button>
	</form>
	<div id="log-table">
		<table>
			<thead>
				<tr>
					<th>Дата и время</th>
					<th>Номер телефона</th>
					<th>Сообщение</th>
					<th>Статус</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
</body>
</html>

Код CSS файла (style.css):

body {
	font-family: Arial, sans-serif;
}

form {
	margin-bottom: 20px;
}

label {
	display: block;
	margin-bottom: 5px;
}

input[type="text"],
textarea {
	width: 100%;
	padding: 5px;
	border: 1px solid #ccc;
	border-radius: 3px;
}

input[type="number"] {
	width: 50px;
}

button[type="submit"] {
	background-color: #4CAF50;
	color: white;
	padding: 10px 20px;
	border: none;
	border-radius: 3px;
	cursor: pointer;
}

button[type="submit"]:hover {
	background-color: #3e8e41;
}

#log-table {
	width: 100%;
}

#log-table table {
	border-collapse: collapse;
	width: 100%;
}

#log-table th,
#log-table td {
	padding: 10px;
	border: 1px solid #ccc;
	text-align: center;
}

#log-table th {
	background-color: #f2f2f2;
}

Код JS файла (script.js):

$(document).ready(function() {
	$('#sms-form').submit(function(event) {
		event.preventDefault();
		var phone = $('#phone').val();
		var message = $('#message').val();
		var count = $('#count').val();
		for (var i = 1; i <= count; i++) {
			sendSms(phone, message, i);
		}
	});

	function sendSms(phone, message, index) {
		$.ajax({
			url: 'send_sms.php',
			method: 'POST',
			data: {
				phone: phone,
				message: message
			},
			success: function(data) {
				var status;
				if (data == 'success') {
					status = 'Отправлено';
				} else {
					status = 'Ошибка';
				}
				var logRow = '<tr><td>' + getCurrentDateTime() + '</td><td>' + phone + '</td><td>' + message + '</td><td>' + status + '</td></tr>';
				$('#log-table tbody').append(logRow);
			},
			error: function() {
				var logRow = '<tr><td>' + getCurrentDateTime() + '</td><td>' + phone + '</td><td>' + message + '</td><td>Ошибка</td></tr>';
				$('#log-table tbody').append(logRow);
			}
		});
	}

	function getCurrentDateTime() {
		var currentDateTime = new Date();
		var day = currentDateTime.getDate();
		var month = currentDateTime.getMonth() + 1;
		var year = currentDateTime.getFullYear();
		var hours = currentDateTime.getHours();
		var minutes = currentDateTime.getMinutes();
		var seconds = currentDateTime.getSeconds();
		day = day < 10 ? '0' + day : day;
		month = month < 10 ? '0' + month : month;
		hours = hours < 10 ? '0' + hours : hours;
		minutes = minutes < 10 ? '0' + minutes : minutes;
		seconds = seconds < 10 ? '0' + seconds : seconds;
		return day + '.' + month + '.' + year + ' ' + hours + ':' + minutes + ':' + seconds;
	}
});

Код PHP файла (send_sms.php):

<?php

// Получаем данные из POST-запроса
$phone = $_POST['phone'];
$message = $_POST['message'];

// Отправляем SMS и возвращаем результат
if (sendSms($phone, $message)) {
    echo 'success';
} else {
    echo 'error';
}

function sendSms($phone, $message) {
    // Код отправки SMS
    return true; // Возвращаем true или false в зависимости от результата отправки
}

?>
Напиши код html сайта в котором будет отправка смс в определённом количестве Также напиши коды css js и php файлов На html странице сделай лог таблицу где будут написаны все происходящие действия и ре

原文地址: https://www.cveoy.top/t/topic/bGWT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录