我的 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 關注
- 113 瀏覽
添加回答
舉報
0/150
提交
取消