PHP が Ajax 投稿フォームを受け入れ、TXT を別の行に保存する方法を手伝ってください
JS コードは次のとおりです
function SubmitApply() {<br /> var form = Global.GetElement("#submitForm");<br /> var UserName = Global.GetElement(form, 'input[name="Name"]').value;<br /> var Mobile = Global.GetElement(form, 'input[name="Tel"]').value;<br /> var Position = Global.GetElement(form, 'input[name="Position"]').value;<br /> var Company = Global.GetElement(form, 'input[name="Company"]').value;<br /> var ActId = Global.GetElement(form, 'input[name="Actid"]').value;<br /> if (Global.IsNullOrWhitesapce(UserName)) {<br /> Global.Tip.TipError("姓名必须填写");<br /> return;<br /> }<br /> if (Global.IsNullOrWhitesapce(Mobile)) {<br /> Global.Tip.TipError("手机必须填写");<br /> return;<br /> }<br /> if (/^1[3|4|5|8][0-9]\d{4,8}$/.test(Mobile) == false) {<br /> Global.Tip.TipError("手机格式不正确");<br /> return;<br /> }<br /> var ajaxRequest = new HttpAjaxRequest();<br /> ajaxRequest.ajax({<br /> dataType: 'json',<br /> url: '',<br /> data: { name: UserName, mobile: Mobile, companyname: Company, position: Position, actid: ActId },<br /> successed: OnSubmitAppplySuccesse,<br /> error: function () {<br /> Global.Tip.TipError('提交失败!');<br /> GlobalPlayer.DisableNext();<br /> }<br /> });<br />}<br /><br />/**<br /> * 名称:申请提交成功<br /> */<br />function OnSubmitAppplySuccesse(data) {<br /> if (data.Code == 0) {<br /> Global.Tip.TipMessage('提交成功!');<br /> var form = Global.GetElement("#submitForm");<br /> GlobalPlayer.EnableNext();<br /> GlobalPlayer.PlayNext();<br /> form.reset();<br /> } else {<br /> Global.Tip.TipError('提交失败!' + data.Message);<br /> GlobalPlayer.DisableNext();<br /> }<br />}
<br />$name = $_POST['name'];<br />$mobile = $_POST['mobile'];<br />$companyname = $_POST['companyname'];<br />$actid = $_POST['actid'];<br />$position = $_POST['position'];<br /> $str =$name. "\n".$mobile."\n".$companyname."\n".$actid."\n".$position;<br />$h = fopen('./t.txt','w');<br />fwrite($h,$str);<br />fclose($h);<br />