php - PHP 无法从邮件程序中获取返回值
问题描述
我的网站上有一个联系表。我想让 PHP 邮件程序工作,我从表单中获取输入并返回 1 表示成功,否则返回 -1 错误。我想包括那个,我已经收集了邮件文件。
这是我得到的错误。
注意:未定义索引:C:\xampp\htdocs\omnifood\index.php 中的成功
此 php 代码获取 mailer.php 文件返回的值。
<?php
if ($_GET['success'] == 1) {
echo "<div class=\"form-message success\"> Thank you. Your message has been sent ! </div>";
}
if ($_GET['success'] == -1) {
echo "<div class=\"form-message error\"> Opps! Something went wrong. Please try again. </div>";
}
?>
这是发生任何错误时返回值的代码。
if (empty($name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: localhost:8080/omnifood/index.php?success=-1#form");
exit;
}
成功发送邮件后,会返回。
header("Location: localhost:8080/omnifood/index.php?success=1#form");
解决方案
推荐阅读
- c++ - 致命错误:找不到“boost/test/unit_test.hpp”文件
- javascript - 存储迭代计数,然后在 javascript 中的 for 循环之外访问它
- javascript - 在对象文字中引用javascript中嵌套对象的外层
- reactjs - 在 next.js 中获取客户端的当前 url
- angular - 如何强制我的函数按顺序调用?
- python - 无法将字符串与符号进行比较?
- javascript - React Native 按钮按下以控制导入的类状态
- symfony4 - 正确的请求 URL PHPUnit 功能测试 Symfony 4.2
- python - 将命令输出表转换为字典
- python - 将 selenium webdriver 作为 python 程序的参数传递