我的 From 有问题。出于某种原因,当我提交表单时,电子邮件没有保存到数据库中。我的 html/js 进行了两次 Async - Await Ajax 调用。第一个授予用户互联网访问权限(热点),而第二个将电子邮件保存到数据库中。路由器(热点)与服务器位于不同的网络上。请注意,第一个 xhr 有效(用户可以访问互联网),第二个表单报告 XHR2 4 和 XHR2 200,但电子邮件未保存到数据库中。我(目前)正在使用 XAMPP,如果那是相关的话。我还添加ServerName 10.30.20.30:80了 httpd.config 文件。如果我可以提供任何其他信息,请告诉我。任何解决此问题的帮助将不胜感激。<?php require ('connect.php'); $clean_email = ""; $cleaner_email = ""; if(isset($_POST['Email']) && !empty($_POST['Email'])){ //sanitize with filter $clean_email = filter_var($_POST['Email'], FILTER_SANITIZE_EMAIL); //sanitize with test_input $cleaner_email = test_input($clean_email); //validate with filter if (filter_var($cleaner_email,FILTER_VALIDATE_EMAIL)){ // email is valid and ready for use echo "Email is valid"; //Email is a column in the Database $stmt = $DB->prepare("INSERT INTO naslovi (Email) VALUES (?)"); $stmt->bind_param("s", $cleaner_email); $stmt->execute(); $stmt->close(); } else { // email is invalid and should be rejected echo "Invalid email, try again"; } } else { echo "Please enter an email"; } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $DB->close(); ?>
- 1 回答
- 0 关注
- 96 浏览
添加回答
举报
0/150
提交
取消