简体   繁体   English

PHP 发送邮件不起作用并且值索引无法访问

[英]PHP sending mail is not working and index of value is unreachable

I used to post and action method to send mail.我用post和action方法来发送邮件。 I tried to send short mail from hosting server by running test PHP.我尝试通过运行测试 PHP 从托管服务器发送短邮件。 It was working.它正在工作。 After merging it with HTML form is not working and also giving error undefined index.将其与 HTML 合并后,表单无法正常工作并且还会给出错误未定义索引。 Here is the summary of the code.这是代码的摘要。
HTML file: 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 file: PHP 文件:

<?php
if(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 File: 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;   
}

My Live form on GitHub, you check - https://tamzid958.github.io/multipage_form/我在 GitHub 上的 Live 表格,你检查一下 - https://tamzid958.github.io/multipage_form/

The PHP file in your form is not working as https://tamzid958.github.io/multipage_form/ as a hosting is not parsing PHP at all. The PHP file in your form is not working as https://tamzid958.github.io/multipage_form/ as a hosting is not parsing PHP at all. This hosting is only for static pages, like HTML, JS, CSS.此托管仅适用于 static 页面,例如 HTML、JS、CSS。

You need to put your code on a hosting that supports PHP..您需要将代码放在支持 PHP 的主机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM