Jump to content

Recommended Posts

Hey everyone,

 

I am having some trouble with a simple form I have created. When the form is submitted, it is suppose to show you confirmation (which is does just fine) and send an email to me with the information from the form. For some reason, I am not receiving the email!! I've looked it over a bunch of time and not sure what I am missing. Could someone take a quick peek for me?!

 

Here is the code

 

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];

?>

<form method="POST" action="online_application_confirmation.php" onSubmit="" name="Application Form">
     
    <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="table42">
      <tr>
        <td width="100%"><font face="Arial"><font size="2">Date: </font>
        <select size="1" name="Month_Applying">
        <option selected>Select Month</option>
        <option>January</option>
        <option>February</option>
        <option>March</option>
        <option>April</option>
        <option>May</option>
        <option>June</option>
        <option>July</option>
        <option>August</option>
        <option>September</option>
        <option>October</option>
        <option>November</option>
        <option>December</option>
        </select><font size="2"> </font><select size="1" name="Day_Applying">
        <option selected>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
        <option>9</option>
        <option>10</option>
        <option>11</option>
        <option>12</option>
        <option>13</option>
        <option>14</option>
        <option>15</option>
        <option>16</option>
        <option>17</option>
        <option>18</option>
        <option>19</option>
        <option>20</option>
        <option>21</option>
        <option>22</option>
        <option>23</option>
        <option>24</option>
        <option>25</option>
        <option>26</option>
        <option>27</option>
        <option>28</option>
        <option>29</option>
        <option>30</option>
        <option>31</option>
        </select><font size="2">, 2008.</font></font><p>
          <br>
     I, 
          <input type="text" name="Person_Applying" size="25" value="Please enter your full name">,
          <font face="Arial" size="2">apply for membership to your Order, to the 
          Officers and Members of<br>
          <select size="1" name="Closest_City_To_Person_Applying">
          <option selected>Please pick the closest city to you...</option>
          <option>Ancaster</option>
          <option>Amprior</option>
          <option>Aurora</option>
          <option>Aylmer</option>
          <option>Barrie</option>
          <option>Beachville</option>
          <option>Belleville</option>
          <option>Belmont</option>
          <option>Blenheim</option>
          <option>Bowmanville</option>
          <option>Bracebridge</option>
          <option>Brampton</option>
          <option>Brantford</option>
          <option>Brinston</option>
          <option>Brockville</option>
          <option>Brooklin</option>
          <option>Brucefield</option>
          <option>Brussels</option>
          <option>Burford</option>
          <option>Cambridge</option>
          <option>Campbellford</option>
          <option>Cayuga</option>
          <option>Chapleau</option>
          <option>Cobourg</option>
          <option>Collingwood</option>
          <option>Delhi</option>
          <option>Dresden</option>
          <option>Dundas</option>
          <option>Durham</option>
          <option>Dutton</option>
          <option>Elmvale</option>
          <option>Essex</option>
          <option>Etobicoke</option>
          <option>Exeter</option>
          <option>Florence</option>
          <option>Forest</option>
          <option>Gananoque</option>
          <option>Glanworth</option>
          <option>Glencoe</option>
          <option>Gravenhurst</option>
          <option>Guelph</option>
          <option>Hamilton</option>
          <option>Harrietsville</option>
          <option>Harrow</option>
          <option>Harrowsmith</option>
          <option>Havelock</option>
          <option>Huntsville</option>
          <option>Ingersol</option>
          <option>Ingleside</option>
          <option>Jarvis</option>
          <option>Keewatin</option>
          <option>Kemptville</option>
          <option>Kincardine</option>
          <option>Kingston</option>
          <option>Little Britain</option>
          <option>London</option>
          <option>Lyn</option>
          <option>Madac</option>
          <option>Melbourne</option>
          <option>Midland</option>
          <option>Millbrook</option>
          <option>Milton</option>
          <option>Mooretown</option>
          <option>Mount Brydges</option>
          <option>Nepean</option>
          <option>North Bay</option>
          <option>Oakville</option>
          <option>Oil Springs</option>
          <option>Orillia</option>
          <option>Orangeville</option>
          <option>Osgoode</option>
          <option>Ottawa</option>
          <option>Parham</option>
          <option>Parry Sound</option>
          <option>Peterborough</option>
          <option>Petrolia</option>
          <option>Picton</option>
          <option>Port Colborne</option>
          <option>Port Hope</option>
          <option>Port Perry</option>
          <option>Prescott</option>
          <option>Princeton</option>
          <option>Ridgetown</option>
          <option>Ruthven</option>
          <option>Sault Ste. Marie</option>
          <option>Shedden</option>
          <option>Simcoe</option>
          <option>South Mountain</option>
          <option>Springfield</option>
          <option>St. Catharines</option>
          <option>St. Marys</option>
          <option>St. Thomas</option>
          <option>Stratford</option>
          <option>Sudbury</option>
          <option>Tara</option>
          <option>Thamesford</option>
          <option>Thamesville</option>
          <option>Thessalon</option>
          <option>Thornbury</option>
          <option>Thunder Bay</option>
          <option>Tillsburg</option>
          <option>Tiverton</option>
          <option>Toronto</option>
          <option>Trenton</option>
          <option>Tweed</option>
          <option>Wallaceburg</option>
          <option>Wheatley</option>
          <option>Whitby</option>
          <option>Wiarton</option>
          <option>Williamsburg</option>
          <option>Woodslee</option>
          <option>Wyoming</option>
          </select>, 
          Independent Order of Odd Fellows, working under the jurisdiction of 
          the Grand Lodge of Ontario of the Independent Order of Odd Fellows.<br>
          <br>
     I respectfully request admission into your Lodge by 
          initiation and I promise and agree that, if elected, I will conform to 
          the Constitution and Bylaws of your Lodge and those governing the 
          Grand Lodge of Ontario. I will seek remedy for all rights on account 
          of said membership or connection therewith in the tribunals of the 
          Order only, without resorting to their enforcement in any event, or 
          for any purpose, to the civil courts. <br>
          <br>
     I believe in a Supreme Being and I am loyal to my 
          country.<br>
          <br>
          Sponsor (if any,):<input type="text" name="Sponsors_Name" size="35" value="Enter Sponsor's Name here"> 
          and
          <select size="1" name="Sponsors_Lodge_Name">
          <option selected>Please pick your Sponsors Lodge</option>
          <option>I am not sure what it is</option>
          <option>Ancaster</option>
          <option>Amprior</option>
          <option>Aurora</option>
          <option>Aylmer</option>
          <option>Barrie</option>
          <option>Beachville</option>
          <option>Belleville</option>
          <option>Belmont</option>
          <option>Blenheim</option>
          <option>Bowmanville</option>
          <option>Bracebridge</option>
          <option>Brampton</option>
          <option>Brantford</option>
          <option>Brinston</option>
          <option>Brockville</option>
          <option>Brooklin</option>
          <option>Brucefield</option>
          <option>Brussels</option>
          <option>Burford</option>
          <option>Cambridge</option>
          <option>Campbellford</option>
          <option>Cayuga</option>
          <option>Chapleau</option>
          <option>Cobourg</option>
          <option>Collingwood</option>
          <option>Delhi</option>
          <option>Dresden</option>
          <option>Dundas</option>
          <option>Durham</option>
          <option>Dutton</option>
          <option>Elmvale</option>
          <option>Essex</option>
          <option>Etobicoke</option>
          <option>Exeter</option>
          <option>Florence</option>
          <option>Forest</option>
          <option>Gananoque</option>
          <option>Glanworth</option>
          <option>Glencoe</option>
          <option>Gravenhurst</option>
          <option>Guelph</option>
          <option>Hamilton</option>
          <option>Harrietsville</option>
          <option>Harrow</option>
          <option>Harrowsmith</option>
          <option>Havelock</option>
          <option>Huntsville</option>
          <option>Ingersol</option>
          <option>Ingleside</option>
          <option>Jarvis</option>
          <option>Keewatin</option>
          <option>Kemptville</option>
          <option>Kincardine</option>
          <option>Kingston</option>
          <option>Little Britain</option>
          <option>London</option>
          <option>Lyn</option>
          <option>Madac</option>
          <option>Melbourne</option>
          <option>Midland</option>
          <option>Millbrook</option>
          <option>Milton</option>
          <option>Mooretown</option>
          <option>Mount Brydges</option>
          <option>Nepean</option>
          <option>North Bay</option>
          <option>Oakville</option>
          <option>Oil Springs</option>
          <option>Orillia</option>
          <option>Orangeville</option>
          <option>Osgoode</option>
          <option>Ottawa</option>
          <option>Parham</option>
          <option>Parry Sound</option>
          <option>Peterborough</option>
          <option>Petrolia</option>
          <option>Picton</option>
          <option>Port Colborne</option>
          <option>Port Hope</option>
          <option>Port Perry</option>
          <option>Prescott</option>
          <option>Princeton</option>
          <option>Ridgetown</option>
          <option>Ruthven</option>
          <option>Sault Ste. Marie</option>
          <option>Shedden</option>
          <option>Simcoe</option>
          <option>South Mountain</option>
          <option>Springfield</option>
          <option>St. Catharines</option>
          <option>St. Marys</option>
          <option>St. Thomas</option>
          <option>Stratford</option>
          <option>Sudbury</option>
          <option>Tara</option>
          <option>Thamesford</option>
          <option>Thamesville</option>
          <option>Thessalon</option>
          <option>Thornbury</option>
          <option>Thunder Bay</option>
          <option>Tillsburg</option>
          <option>Tiverton</option>
          <option>Toronto</option>
          <option>Trenton</option>
          <option>Tweed</option>
          <option>Wallaceburg</option>
          <option>Wheatley</option>
          <option>Whitby</option>
          <option>Wiarton</option>
          <option>Williamsburg</option>
          <option>Woodslee</option>
          <option>Wyoming</option>
          </select><br>
          <br>
          <i>Applicant Information:<br>
          <br>
          </i>Name: 
          <input type="text" name="Applicants_Name" size="40" value="Please enter your Full Name"><br>
          <br>
          I was born in 
          <input type="text" name="Applicants_City_Of_Birth" size="30" value="The city you were born in"> on the
          <select size="1" name="Day_Born">
          <option selected>1st</option>
          <option>2nd</option>
          <option>3rd</option>
          <option>4th</option>
          <option>5th</option>
          <option>6th</option>
          <option>7th</option>
          <option>8th</option>
          <option>9th</option>
          <option>10th</option>
          <option>11th</option>
          <option>12th</option>
          <option>13th</option>
          <option>14th</option>
          <option>15th</option>
          <option>16th</option>
          <option>17th</option>
          <option>18th</option>
          <option>19th</option>
          <option>20th</option>
          <option>21st</option>
          <option>22nd</option>
          <option>23rd</option>
          <option>24th</option>
          <option>25th</option>
          <option>26th</option>
          <option>27th</option>
          <option>28th</option>
          <option>29th</option>
          <option>30th</option>
          <option>31st</option>
          </select> day of <select size="1" name="Month_Born">
          <option selected>Select Month</option>
          <option>January</option>
          <option>February</option>
          <option>March</option>
          <option>April</option>
          <option>May</option>
          <option>June</option>
          <option>July</option>
          <option>August</option>
          <option>September</option>
          <option>October</option>
          <option>November</option>
          <option>December</option>
          </select>, <select size="1" name="Year_Born">
          <option>1925</option>
          <option>1926</option>
          <option>1927</option>
          <option>1928</option>
          <option>1929</option>
          <option>1930</option>
          <option>1931</option>
          <option>1932</option>
          <option>1933</option>
          <option>1934</option>
          <option>1935</option>
          <option>1936</option>
          <option>1937</option>
          <option>1938</option>
          <option>1939</option>
          <option>1940</option>
          <option>1941</option>
          <option>1942</option>
          <option>1943</option>
          <option>1944</option>
          <option>1945</option>
          <option>1946</option>
          <option>1947</option>
          <option>1948</option>
          <option>1949</option>
          <option selected>1950</option>
          <option>1951</option>
          <option>1952</option>
          <option>1953</option>
          <option>1954</option>
          <option>1955</option>
          <option>1956</option>
          <option>1957</option>
          <option>1958</option>
          <option>1959</option>
          <option>1960</option>
          <option>1961</option>
          <option>1962</option>
          <option>1963</option>
          <option>1964</option>
          <option>1965</option>
          <option>1966</option>
          <option>1967</option>
          <option>1968</option>
          <option>1969</option>
          <option>1970</option>
          <option>1971</option>
          <option>1972</option>
          <option>1973</option>
          <option>1974</option>
          <option>1975</option>
          <option>1976</option>
          <option>1977</option>
          <option>1978</option>
          <option>1979</option>
          <option>1980</option>
          <option>1981</option>
          <option>1982</option>
          <option>1983</option>
          <option>1984</option>
          <option>1985</option>
          <option>1986</option>
          <option>1987</option>
          <option>1988</option>
          <option>1989</option>
          <option>1990</option>
          <option>1991</option>
          <option>1992</option>
          <option>1993</option>
          <option>1994</option>
          <option>1995</option>
          <option>1996</option>
          <option>1997</option>
          <option>1998</option>
          <option>1999</option>
          <option>2000</option>
          <option>2001</option>
          <option>2002</option>
          <option>2003</option>
          <option>2004</option>
          </select>.<br>
          <br>
          Street Address:</font><font face="Arial">
      <input type="text" name="Applicants_Address" size="28">    </font>
      <font size="2" face="Arial"> City:</font><font face="Arial">
      <input type="text" name="Applicants_City" size="24"><br>
          <br>
      </font>
      <font size="2" face="Arial">Province: 
          <select size="1" name="Applicants_Province">
          <option>Alberta</option>
          <option>British Columbia</option>
          <option>Manitoba</option>
          <option>New Brunswick</option>
          <option>Newfoundland & Labrador</option>
          <option>Northwest Territories</option>
          <option>Nova Scotia</option>
          <option>Nunavut</option>
          <option selected>Ontario</option>
          <option>Prince Edward Island</option>
          <option>Quebec</option>
          <option>Saskatchewan</option>
          <option>Yukon</option>
          </select>     Postal Code: </font><font face="Arial"> 
          <input type="text" name="Applicants_Postal_Code" size="7"><br>
          <br>
      </font>
      <font size="2" face="Arial">Home Phone Number: </font>
      <font face="Arial">
      <input type="text" name="Applicants_Home_Phone_Number" size="12">    
          Email Address: 
          <input type="text" name="Applicants_Email_Address" size="25" value="No email, just leave empty"><br>
          <font size="1">(Phone Number with area code)</font><br>
          <br>
      </font>
      <font size="2" face="Arial">Applicant's 
          Signature:_____________________________<br>
                                   
      </font><font face="Arial" size="1">To Be Signed at a later date.<br>
 </font></p>
          <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="table43">
            <tr>
              <td width="100%">
              <p align="center"><input type="submit" value="Submit" name="B1">    
              <input type="reset" value="Reset" name="B2"></td>
            </tr>
          </table>
        
        </td>
      </tr>
    </table></form>
<?php
   } else {
      error_reporting(0);
      $recipient = 'sgigacz@cyg.net';
  $Month_Applying = stripslashes($_POST['Month_Applying']);
      $Day_Applying = stripslashes($_POST['Day_Applying']);
  $Person_Applying = stripslashes($_POST['Person_Applying']);
  $Closest_City_To_Person_Applying = stripslashes($_POST['Closest_City_To_Person_Applying']);
      $Sponsors_Name = stripslashes($_POST['Sponsors_Name']);
      $Sponsors_Lodge_Name = stripslashes($_POST['Sponsors_Lodge_Name']);
      $Applicants_Name = stripslashes($_POST['Applicants_Name']);
  $Applicants_City_Of_Birth = stripslashes($_POST['Applicants_City_Of_Birth']);
      $Day_Born = stripslashes($_POST['Day_Born']);
      $Month_Born = stripslashes($_POST['Month_Born']);
      $Year_Born = stripslashes($_POST['Year_Born']);
  $Applicants_Address = stripslashes($_POST['Applicants_Address']);
  $Applicants_City = stripslashes($_POST['Applicants_City']);
  $Applicants_Province = stripslashes($_POST['Applicants_Province']);
  $Applicants_Postal_Code = stripslashes($_POST['Applicants_Postal_Code']);
  $Applicants_Home_Phone_Number = stripslashes($_POST['Applicants_Home_Phone_Number']);
  $Applicants_Email_Address = stripslashes($_POST['Applicants_Email_Address']);
     
      
      $headers = "From: $Applicants_Email_Address\r\n\r\n";
      $subject = "Online Application Form";
      $message = "Month Applying: $Month_Applying\r\n
      Day Applying: $Day_Applying\r\n
      Person Applying: $Person_Applying\r\n
      Closest City To Person Applying: $Closest_City_To_Person_Applying\r\n
      Sponsors Name: $Sponsors_Name\r\n
      Sponsors Lodge Name: $Sponsors_Lodge_Name\r\n
      Applicants Name: $Applicants_Name\r\n
      Applicants City Of Birth: $Applicants_City_Of_Birth\r\n
      Day Born: $Day_Born\r\n
  Month Born: $Month_Born\r\n
  Year Born: $Year_Born\r\n
  Applicants Address: $Applicants_Address\r\n
  Applicants City: $Applicants_City\r\n
  Applicants Province: $Applicants_Province\r\n
  Applicants Postal Code: $Applicants_Postal_Code\r\n
  Applicants Home Phone Number: $Applicants_Home_Phone_Number\r\n
  Applicants Email Address: $Applicants_Email_Address\r\n
      <br />
      "; 
      mail($recipient, $subject, $message, $headers);
      if (!mail) {
          echo "Message failed to send";
      } else {
          
      }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/120286-not-receiving-email-from-submitted-form/
Share on other sites

You may already know this but, to send mail from PHP your need to use an SMTP mail server.

Then you need to configure it in your php.ini file. If you have already done these things,

then if you are running all of this on your computer, check your SMTP server for errors.

Since it is not showing the error message the message got to the server.

I can't find anything wrong with your code so... I would look at your SMTP server.

I have a few other forms running off of the same server, and they all seem fine. The only different between them and this form, is that is takes you to the  seperate confirmation page where are the other ones give a confirmation on the same page. I am pretty new to PHP, so im not sure if that would make a difference or not

The first thing to troubleshoot mail() issues is to keep it simple to start

 

mail("youremail@email.com", "Subject", "Message", "FROM: youremail@email.com");

 

Replace "youremail@email.com" with your email on that domain with the webhost.

ok, so I have figured out this much. I wonder if it has something to do with

 

<?php

if ($_SERVER['REQUEST_METHOD'] != 'POST'){

      $me = $_SERVER['PHP_SELF'];

 

?>

 

<form method="POST" action="online_application_confirmation.php" onSubmit="" name="Application Form">

 

When I change the action to "<?php echo $me;?>" i get the email confirmation, but of course it just shows the confirmation on the same page. If i leave it as above, it goes to the seperate confirmation page, but I do not get the email...

would it have anything to do with this  $me = $SERVER['PHP_SELF'];    ? because it is not going to itself, it is going to another page?

If you used the mail function:

 

mail("youremail@email.com", "Subject", "Message", "FROM: youremail@email.com");

 

And you still dident receive an email at the email that you replaced in the example, then you're server's SMTP server is either not set-up correctly or not currently functioning. So what you need to do is to email your webhost to make sure you have access to an SMTP server in the first place - if you do then ask them to fix it.

Hey everyone. I finally found some time to finish off with this form and I believe the problem is coming from the cofirmation page. I need to put some scripting that will send the email itself. I have the scripting to copy the var over to the confirmation page, but the email doesnt come to me. Here is the code for the confirmation page. Any help would be great.

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Online Application Confirmation</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Theme" content="none, default">
<meta name="Microsoft Border" content="none, default">
</head>

<body>

<div align="left">
<table border="0" width="100%" cellspacing="5" cellpadding="5" id="table44">
	<tr>
		<td valign="top" width="100%">
		<div align="left">
			<table border="0" width="100%" cellspacing="0" cellpadding="5" id="table45">
				<tr>
					<td>
					<p align="center">
					<font face="Arial Black" style="font-size: 26pt" color="#000080">
					Application Confirmation - Thank You</font></td>
					<td width="15%">
					<p align="center">
					<img border="0" src="images/Odd%20Fellow%20Logo.gif" width="160" height="50"></td>
				</tr>
			</table>
			<div align="left">
				<table border="1" width="100%" id="table46">
					<tr>
						<td>





						<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table47">
							<tr>
								<td>
						<font size="2" face="Arial"><br>
						Dear
						<strong><?php echo $_POST['Applicants_Name']; ?></strong>,</font><p>
						<font size="2" face="Arial">Thank you for sending us 
						your
						application. We will be forwarding your application 
						to the lodge nearest your home and have someone 
						contact you in the next<br>
						couple of business days, we will be 
						using the following information:</font></p>
						<blockquote>
							<p><font face="Arial"><strong><font size="2">
							Name: </font></strong></font>
						<font size="2" face="Arial">
						<strong><?php echo $_POST['Applicants_Name']; ?></strong></font><font face="Arial"><strong><font size="2"><br>
							Address: </font></strong><font size="2">
						<strong><?php echo $_POST['Applicants_Address']; ?></strong></font><strong><font size="2"><br>
							City: </font></strong><font size="2">
							<strong><?php echo $_POST['Applicants_City']; ?></strong></font><strong><font size="2"><br>
							Postal Code: </font></strong><font size="2">
							<strong><?php echo $_POST['Applicants_Postal_Code']; ?></strong></font><strong><font size="2"><br>
							</font></strong><font size="2">
							<strong>Telephone:</strong>
						<strong><?php echo $_POST['Applicants_Home_Phone_Number']; ?></strong></font><strong><font size="2"><br>
							E-mail:</font></strong><font size="2">
							<strong><?php echo $_POST['Applicants_Email_Address']; ?></strong><br>
							 </font></font></p>
						</blockquote>
						<p><font size="2" face="Arial">If any of this 
						information is incorrect, please go back (use your 
						browsers back button) to the 
						feedback form and change it. We thank you for taking 
						the time to help us be a become a larger 
						Organization.</font></p>
						<blockquote>
							<blockquote>
								<blockquote>
									<p><font size="2" face="Arial">
									Sincerely,<br>
									<br>
									</font><font face="Lucida Calligraphy">
									<b>Barry Smith</b></font></p>
									<p><em><font face="Arial" size="2">Barry 
									Smith, Webmaster for The Grand Lodge of 
									Ontario of the Independent Order of Odd 
									Fellows</font></em></p>
								</blockquote>
							</blockquote>
						</blockquote>
						<hr>
						<p align="center"><font face="Arial" size="2"><a href="javascript:window.close();">Click here to Close this Window</a></font><br>
 </td>
							</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
		</td>
	</tr>
	</table>
</div>

</body>

</html>

Hi,

 

The code that you first posted contains the call to the mail function, is that page called online_application_confirmation.php ?

 

You mentioned that the page redirects to a confirmation page which is the code snippet above ? this page does not have any call to the mail function in it

 

The way your doing error checking to see if the mail has been sent in the first page is incorrect.

 

Possible solutions to your problem are to.

 

1. move the call to the mail function to the page online_application_confirmation.php this should send the email out to you if it's configured correctly

2. change the form action to be the page the form is on and then do a redirect after the mail function call (on a successful mail out or show the form again)

 

Regards,

 

A

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.