It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Problems with a HTML form

Problems with a HTML form

Postby xJochemx on Sat Jan 22, 2011 8:43 am

Hi everyone,

I've made a form in HTML using php for processing so people can sign a petition. The data entered in the form is send by email to the initiator of the petition. It's going pretty well, however, he regularly gets emails containg only two stripes ("- -"). That would be just the symbols in between the birth date. This seems strange to me as I've set all fields as mandatory. I'm new to making forms and using php though.
Does anyone know what the problem could be?

Here's (most of the) the HTML form. The site is in Dutch, some important words: Geboorte=birth, datum=date, dag=day, maand=month, jaar=year. If you need more information, please let me know.

Code: Select all
<script language="JavaScript">
<!--

/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function formCheck(formobj){
   // Enter name of mandatory fields
   var fieldRequired = Array("VoorNaam", "AchterNaam", "Adres", "PostCode", "PlaatsNaam", "GeboorteDatum", "GeboorteDatumDag", "GeboorteDatumMaand", "GeboorteDatumJaar");
   // Enter field description to appear in the dialog box
   var fieldDescription = Array("VoorNaam", "AchterNaam", "Adres", "PostCode", "PlaatsNaam", "GeboorteDatum", "GeboorteDatumDag", "GeboorteDatumMaand", "GeboorteDatumJaar");
   // dialog message
   var alertMsg = "Vul alstublieft het volgende veld in:\n";
   
   var l_Msg = alertMsg.length;
   
   for (var i = 0; i < fieldRequired.length; i++){
      var obj = formobj.elements[fieldRequired[i]];
      if (obj){
         switch(obj.type){
         case "select-one":
            if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
               alertMsg += " - " + fieldDescription[i] + "\n";
            }
            break;
         case "select-multiple":
            if (obj.selectedIndex == -1){
               alertMsg += " - " + fieldDescription[i] + "\n";
            }
            break;
         case "text":
         case "textarea":
            if (obj.value == "" || obj.value == null){
               alertMsg += " - " + fieldDescription[i] + "\n";
            }
            break;
         default:
         }
         if (obj.type == undefined){
            var blnchecked = false;
            for (var j = 0; j < obj.length; j++){
               if (obj[j].checked){
                  blnchecked = true;
               }
            }
            if (!blnchecked){
               alertMsg += " - " + fieldDescription[i] + "\n";
            }
         }
      }
   }

   if (alertMsg.length == l_Msg){
      return true;
   }else{
      alert(alertMsg);
      return false;
   }
}
// -->
</script>

</head>
<body>

<form action="FormulierAfhandeling.php" method="post" onsubmit="return formCheck(this);">
<INPUT TYPE="hidden" NAME="required_vars" VALUE="VoorNaam", "AchterNaam", "Adres", "PostCode", "PlaatsNaam", "EmailAdres">
<p>Voornaam: <input name="VoorNaam" type="text" size="30" maxlength="80"></p>
<p>Achternaam: <input name="AchterNaam" type="text" size="30" maxlength="80"></p>
<p>Adres: <input name="Adres" type="text" size="30" maxlength="80"></p>
<p>Postcode: <input name="PostCode" type="text" size="30" maxlength="80"></p>
<p>Plaatsnaam: <input name="PlaatsNaam" type="text" size="30" maxlength="80"></p>
<p>Geboortedatum: <select name="GeboorteDatumDag">
<option selected>-</option>
<option>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> <select name="GeboorteDatumMaand">
<option selected>-</option>
<option>jan</option>
<option>feb</option>
<option>mar</option>
<option>apr</option>
<option>mei</option>
<option>jun</option>
<option>jul</option>
<option>aug</option>
<option>sep</option>
<option>okt</option>
<option>nov</option>
<option>dec</option>
</select> <select name="GeboorteDatumJaar">
<option selected>-</option>
<option>1900</option>
<option>1901</option>
<option>1902</option>
<option>1903</option>
<option>1904</option>
<option>1905</option>
<option>1906</option>
<option>1907</option>
</select></p>

<p>Email: <input name="EmailAdres" type="text" size="30" maxlength="80"></p>

<p><input name="submit" type="submit" value="Bevestigen"></p>


The php file:

Code: Select all
<body>
<?
$VoorNaam = $_POST[VoorNaam];
$AchterNaam = $_POST[AchterNaam];
$GeboorteDatum = $_POST[GeboorteDatum];
$Adres = $_POST[Adres];
$PostCode = $_POST[PostCode];
$PlaatsNaam = $_POST[PlaatsNaam];
$GeboorteDatum = $_POST['GeboorteDatumDag'].'-'.$_POST['GeboorteDatumMaand'].'-'.$_POST['GeboorteDatumJaar'];
$EmailAdres = $_POST[EmailAdres];

$formsent = mail('email@email.com',
      'Ondertekening petitie Ruimte voor vogels',
      "$VoorNaam $AchterNaam
      $GeboorteDatum
      $Adres
      $PostCode $PlaatsNaam",
      "From: $EmailAdres\r\nBounce-to: email@email.com");
   {
   echo "<p>Beste $VoorNaam,<br><br> Hartelijk bedankt voor het ondertekenen van de petitie Ruimte voor Vogels! Vraag zo veel mogelijk
anderen dit ook te doen! U wordt nu teruggeleid naar de beginpagina.</p>";
}
?>
<meta HTTP-EQUIV="REFRESH" content="5"; url=http://www.ruimtevoorvogels.nl/index.html">
</body>


Thanks for any help!
xJochemx
 
Posts: 1
Joined: Sat Jan 22, 2011 8:27 am

Who is online

Users browsing this forum: No registered users and 6 guests