我用post和action方法來發(fā)送郵件。我嘗試通過運行測試 PHP 從托管服務(wù)器發(fā)送短郵件。它正在工作。將其與 HTML 表單合并后不起作用,并且還給出錯誤未定義的索引。這是代碼的摘要。HTML 文件: <form id="msform" action="./php/mailer.php" name="step1" method="POST"> <fieldset> <h2 class="fs-title">Fillup basic Information</h2> <h3 class="fs=subtitle">This is step 1</h3><br> <input type="text" name="fname" placeholder="First Name" required/> <input type="text" name="lname" placeholder="Last Name" required/> <input type="button" name="next" class="next action-button" value="Next" onclick="return validateStep1()"/> </fieldset> </from>PHP 文件:<?phpif(isset($_POST['next'])){$fname = $_POST['fname'];$lname = $_POST['lname']; $msg="Hello My Name is $fname $lname . My Company is $company which is located in $address1 . The Second address is $address2. I live in $city city, $state state, $zip zip, $country. My Phone number is $tel. My Fax number is $fax. My email is $email. I want to donate $other. My Custom Donate is $otherDonation. I want to donate regular=$regulardonate for $dollar dollar per $months"; mail("x@gmail.com","Donation",$msg);}?>JS文件:function validateStep1(){ var fname =document.forms["step1"]["fname"]; var lname =document.forms["step1"]["lname"];if (fname.value == "") { window.alert("Please enter your first name."); fname.focus(); return false; } if (lname.value == "") { window.alert("Please enter your Last name."); lname.focus(); return false; } window.open('./second.html', '_self'); return true; }我在 GitHub 上的 Live 表單,您可以查看 - https://tamzid958.github.io/multipage_form/
1 回答

侃侃無極
TA貢獻(xiàn)2051條經(jīng)驗 獲得超10個贊
因為托管根本不解析 PHP。此托管僅適用于靜態(tài)頁面,例如 HTML、JS、CSS。
您需要將代碼放在支持 PHP 的主機(jī)上。
- 1 回答
- 0 關(guān)注
- 119 瀏覽
添加回答
舉報
0/150
提交
取消