-1
我不確定是什麼問題,但是當提交表單時不會發送電子郵件。下面是代碼:發送郵件功能通過表單不能正常工作
if (isset ($_POST['business_name']) && isset ($_POST['business_address']) && isset ($_POST['business_city']) && isset ($_POST['business_email'])) {
$business_name = $_POST['business_name'];
$business_address = $_POST['business_address'];
$business_city = $_POST['business_city'];
$business_email = $_POST['business_email'];
if (!empty($business_name) && !empty($business_address) &&!empty($business_city) && !empty($business_email)) {
$to = '[email protected]';
$subject = 'New Submission From mywebsite.com';
$body = $business_name. "\n" . $business_address. "\n" . $business_city . "\n" . $business_email;
$headers = "From:" . $business_email;
if (@mail ($to, $subject, $body, $headers))
}
}
///i think everything is there but could be wrong im a beginner
<form action="emailtest.php" method="POST">
<input id="busines_name" type="text" placeholder="Business Name" required> <br />
<input id="business_address" type="text" placeholder="Business Address" required><br />
<input id="business_city" type="text" placeholder="Business City & State" required><br />
<input id="business_email" type="email" placeholder="Your Email Address" required><br />
<input type="submit"value="SUBMIT">
</form>
哪裏是PHP代碼? – Hassaan
你的輸入值需要在'$ _POST'中使用'name'選項 – RST
是的,其實我有名字但是沒有起作用,然後我把它改成了id,而且什麼也沒有。我使用測試代碼檢查了我的服務器,它工作正常。我是否需要名稱和編號? – user2012105