我正在使用 PHP 和 Mailgun API 制作电子邮件订阅表格,但我只收到电子邮件到我在 mailgun.com 上用于创建帐户的主要电子邮件地址。当我用该电子邮件填写表格时,我会收到确认信,但它不适用于其他电子邮件。为什么会这样?这是代码:
初始化文件:
<?php
require_once 'vendor/autoload.php';
define('MAILGUN_KEY', 'key-2ce40f5e23c90b0d666f3e....');
define('MAILGUN_PUBKEY', 'pubkey-8cf7125996....');
define('MAILGUN_DOMAIN', 'sandboxc03eaee7674c4a9094ffa8d61845ddf5.mailgun.org');
define('MAILING_LIST', 'audimas@sandboxc03eaee7674c4a9094ffa8d61845ddf5.mailgun.org');
define('MAILGUN_SECRET', '...');
$mailgun = new Mailgun\Mailgun(MAILGUN_KEY);
$mailgunValidate = new Mailgun\Mailgun(MAILGUN_PUBKEY);
$mailgunOptIn = $mailgun->OptInHandler();
?>
Run Code Online (Sandbox Code Playgroud)
主 index.php 文件:
<?php
require_once 'init.php';
if(isset($_POST['name'], $_POST['email']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$validate = $mailgunValidate->get('address/validate', [
'address' => $email
])->http_response_body;
if($validate->is_valid)
{
$hash = $mailgunOptIn->generateHash(MAILING_LIST, MAILGUN_SECRET, $email);
$mailgun->sendMessage(MAILGUN_DOMAIN, [
'from' => 'noreply@audimas.com',
'to' => $email,
'subject' => 'Please confirm your subscription to us', …Run Code Online (Sandbox Code Playgroud) 当我console.log保存输入值的变量时,它记录一个空字符串。同样的事情发生在alert. 您可以在控制台中测试代码,您将看到输出确实存在,但为空。
(function() {
var button = document.getElementsByTagName("button");
var userInput = document.getElementById("user_input").value;
button[0].addEventListener("click", function() {
console.log(userInput);
}, false);
})();Run Code Online (Sandbox Code Playgroud)
<form>
<input id="user_input" type="text" placeholder="add new task">
<button type="button">Add</button>
</form>Run Code Online (Sandbox Code Playgroud)
截屏:
我需要获取反应式表单输入email并将password它们传递给我的函数,该函数调用注册服务方法以使用电子邮件在 firebase 中注册新用户。不幸的是,在表单提交后,在 Chrome 控制台中我得到RegisterComponent.html:2 ERROR ReferenceError: email is not defined
我的代码现在看起来像这样:
注册.组件.ts
export class RegisterComponent {
form: FormGroup;
constructor(fb: FormBuilder, private authService: AuthService) {
this.form = fb.group({
email:['',Validators.required ],
password:['',Validators.compose([Validators.required,
PasswordValidator.cannotContainSpace])]
})
email = this.form.controls['email'].value;
password = this.form.controls['password'].value;
}
signInWithEmail() {
this.authService.regUser(this.email, this.password);
}
}
Run Code Online (Sandbox Code Playgroud)
我的 AuthService 文件:
regUser() {
firebase.auth().createUserWithEmailAndPassword(email, pass)
.catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
console.log(this.form.controls['email'].value);
}
Run Code Online (Sandbox Code Playgroud)
这只是与问题相关的我的代码的一部分。我没有包括注册表,因为它又大又乱,所以我认为您不需要看到它。提前致谢。
编辑:
注册.component.html …
firebase angular-services firebase-authentication angular angular-reactive-forms
例如,我有一个功能
Question.prototype.checkAnswer = function(answer1, answer2) {
if (answer1.innerHTML == this.correctAnswer) {
console.log("correct");
players1.moveCharacter = true;
pointAmount+= 1;
point.innerHTML = pointAmount;
} else {
console.log("nope")
}
}
Run Code Online (Sandbox Code Playgroud)
答案是正确的id增加1点积分总数.但问题是,如果我不移动到数组中的下一个问题并且只是继续点击答案按钮,我会在我决定继续下一个问题之前继续获得我想要的分数.我怎么能解决这个问题,这样我才能回答这个问题而只能得到一点.我相信我需要确保该函数只运行一次?
这可能很容易解决,但我是新的,不能想到任何东西.
我有一堆 SVG 路径,它们是文本字母。在滚动时,我想offset-path从原始位置开始为它们设置动画。因此,我为属性0x指定0y起始位置offset-path,然后随机指定Line我offset-path想要为 SVG 字母设置动画的位置,如下所示:
path.setAttribute("style", "offset-path: path('M" + 0 +" " + 0 + " L " + generateRandomAnimationPathLine() + " " + generateRandomAnimationPathLine() + "')");
Run Code Online (Sandbox Code Playgroud)
但是,一旦我为所有 SVG 路径提供offset-path随机L属性,它们就已经遍布屏幕并offset-distance设置为0%。这是为什么?offset-distance如果设置为 0,它们不应该留在原点吗?为什么即使设置为 0,SVG 也会从原点移动L?offset-path: path()M
您可以检查每个 SVG 字母并检查offset-distance它们是否已经离开原点。如何从原始位置开始为 SVG 路径设置动画?我试图实现一种效果,当您滚动时,它会慢慢破坏“Hello,World”,当您向上滚动时,它会恢复到原始形式。
图片解释了我想要实现的目标。当 SVG 在屏幕上时,设置offset-path为随机Lines/L,我想通过相对于滚动offset-distance从变为0%来从原始位置对 SVG 字母进行动画处理,如下所示: …