1
votes

I used to post and action method to send mail. I tried to send short mail from hosting server by running test PHP. It was working. After merging it with HTML form is not working and also giving error undefined index. Here is the summary of the code.
HTML file:

     <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
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("[email protected]","Donation",$msg);
}
?>

JS File:

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/

1
Where is the "undefined index" beeing thrown?Amacado
right now the PHP file is not triggering. but if I run the script in the HTML file or if I use window.open('php.file') in JS file. a mail is sending with undefined index error. Name is not capturing right now. The PHP file is not working at all.Tamzid Ahmed

1 Answers

0
votes

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.

You need to put your code on a hosting that supports PHP..