My drop down box isn't validating and comment validation playing games

I have been working with this validation that suit that I am trying to do with my site, but I have come across a couple of issues getting working

[ol][li]I have a drop down box which I would love to make sure that the user selects it, but when I do the validation code and go through the motions of doing the form and miss selecting the one of the drop down box still let the form submit and send the email.[br] Refer to line 15 and 22 of validation code[/li]

[li]I am trying to validate a text area , when you leave the text area blank work by telling me that “Please enter in a message”, but when I enter some text in the text area the validation still tells me “Please enter in a message” when it should be submitting the form and sending the email. I hashed out the validation which is the comment validation and let me submit and send email.[br]Refer to line 45 though to of validation code
[/li][/ol]

Can anyone tell me what going on with the code and why the drop down box isn’t working? Would love someone take a look at the code and see what can be done for me to fix it.
[php]

<?php $myemail = 'root@localhost'; $to = $myemail; If (isset ($_POST['name'] , $_POST['siteArea'] , $_POST['problem'] , $_POST['email'] , $_POST['comment'])) { if (empty($_POST['name'])){ //Validate user Name $errors[] = "Please enter a Name"; } else{ $name = htmlentities($_POST['name']); } if (empty($_POST['siteArea'])){ //Validate user Name $errors[] = "You have not entered where the stie problem is"; } else{ $siteArea = htmlentities($_POST['siteArea']); } if (empty($_POST['problem'])){ //Validate user Name $errors[] = "You have not entered what the problem is"; } else{ $problem = htmlentities($_POST['problem']); } // Validate sending email If(empty($_POST['email'])){ $errors[] = "please enter a validate eMail Address."; }else if(strlen($_POST['email']) > 350){ $errors[] = "Your eMail maybe to long. Please review and correct."; }else if (filter_var($_POST['email'] , FILTER_VALIDATE_EMAIL) === false){ $errors[] = "Please provide your right email address."; }else { $email = "<" .htmlentities($_POST['email']) . ">"; } //// Validate the input message text If(empty($POST['comment'])){ $errors[] = "Please enter in a message."; }else{ $explenation = htmlentities($_POST['comment']); } mail($to, $subject,$message ); } // $from ="from: www.deanross.com.au"; $subject = "Your Lady of interest name: $firstName $lastNamt"; $name = $_POST["name"]; $siteArea = $_POST["siteArea"]; $problem = $_POST["problem"]; $email = $_POST["email"]; $comment = $_POST["comment"]; //--------------------------------------------------Main Message------------------------------------------////// $message = " Dear Dean, My name is $name I have been having a good like though you dating site and I come across this problem which is located in the $siteArea. I found the problem being $problem, I will try to explain a bit better for you about the problem that I have come across. $comment Kind regards $name Email: $email "; ?>

[/php]


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sending a Technical Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex" />
<meta name="robots" content="nofollow" />
</head><body class="mainB" leftmargin="1" topmargin="1" bgproperties="fixed" marginwidth="0">
<?php
	If(empty($errors)=== false){?>
		<ol>
			<?php
				foreach ($errors as $error){
					echo "<li>", $error,"</li>";
				}
			?>
			</ol>
			<?php
			}else{
				If(isset($to, $subject,$message, $headers )){
					mail($to, $subject,$message );
			}
	}
?>
 <table width="75%" align="center" border="0"><form action="" method="post"  name="feedback">
  <tr>
<td> <table width="88%" border="0" align="center" cellpadding="2" cellspacing="3" bordercolor="#FF0066">
                <tr bordercolor="#FF00FF"> 
                  <td align="right"><label for="name" class="dateFormFieldNames">Name</label><br><font class="red">Required</font></td>
                  <td width="79%"><input name="name" id="name" size="16" maxlength="16" class="select2" placeholder="Enter your name" />

                  </td>
                </tr>
                <tr bordercolor="#FF00FF"> 
                  <td width="21%" align="right"><label for="siteArea" class="dateFormFieldNames">Site earea</label><br><font class="red">Required</font></td>
                  <td colspan="3"> <div> 
                      <select name="siteArea" id="siteArea" class="select">
                        <option value=" " selected>Select Site 
                        Area</option>
                        <option value="My Full Bio">My Full Bio</option>
                        <option value="Image  Gallary">Image Gallary</option>
                        <option value="Send me a message">Send me a message</option>
                        <option value="Techical Issues">Techical Issues</option>
                      </select>
                    </div>
</td>
                </tr>
                <tr> 
                  <td align="right"><label for="problem" class="dateFormFieldNames">Problems</label><br><font class="red">Required</font></td>
                  <td colspan="3"><div> 
                      <select name="problem" id="problem" class="select">
                        <option selected>Select the Problem</option>
                        <option value="A Broken link">A Broken link</option>
                        <option value="Page(s) missing">Page(s) missing</option>
                        <option value="Photo(s) missing">Photo(s) missing</option>
                        <option value="Link(s) not working">Link(s) not working</option>
                        <option value="other">>other</option>
                      </select>
                  </div></td>
                </tr>
                <tr bordercolor="#FF00FF"> 
                  <td align="right" bordercolor="#FF00FF" ><label for="email" class="dateFormFieldNames">Email Address</label><br><font class="red">Required</font></td>
                  <td colspan="3"><input name="email" type="text" id="email" class="email" placeholder="Enter your email address" /></td>
                </tr>
                <tr> 
                  <td rowspan="2" align="right"><label for="explenation" class="dateFormFieldNames">Explenation</label><br><font class="red">Required</font></td>
                  <td colspan="3">Please explain in further detail what the problem 
                    maybe and where it is or I have not listed any of the problems 
                    above. Please tell me what they are </td>
                </tr>
                <tr> 
                  <td colspan="3"><textarea name="comment" cols="50" rows="5" id="explenation" placeholder="Enter in your best explaination to where the problem is and what the problem is"></textarea>  </td>
                </tr>
                <tr bordercolor="#FF00FF"> 
                  <td colspan="4" align="center" valign="middle" ><input type="submit" name="submit" value="Submit" onclick="age()" /> 
                  </td>
                </tr>
              </table>
              <br>
              </form>
</td></tr>
</table>

</html>
</body>

[php]if (empty($_POST[‘siteArea’])){[/php]

[php]Select Site Area[/php]

Empty means “”, you have a space in your value, so it’s not empty.

[php]If(empty($POST[‘comment’])){
[/php]

[php][/php]

This is because the ID is explenation not comments so you would need to change it to…

[php]If(empty($POST[‘explenation’])){
[/php]

Also explenation is spelled explanation.

Hi Topcoder
thank you for you last reply. showing me how to fix the drop down box did help a lot thank you, but I still have problem with the comment I chance what you told me to ,but when I still try to submit the form with some text in the comment. The PHP code still ask me to add a comment when I know I did.

[php] //// Validate the input message text
If(empty($POST[‘comment’])){
$errors[] = “Please enter in a message.”;
}else{
$comment = htmlentities($_POST[‘comment’]);
}[/php]

<textarea name="comment" cols="50" rows="5" placeholder="Enter in your best explaination to where the problem is and what the problem is"></textarea> 

Change

[php]
[/php]

to

[php] [/php]

the only difference is that I added id=comment

Hi Topcoder
thank you for all your help. I found where my problem was after I went back and started to retype the piece of code that was not working. it was a mistake that I had made which was a typo all the time and i was looking entirely in the wrong please the piece code I had was missing an under score
this was the code
[php]
If(empty($POST[‘comment’])){
$errors[] = “Please enter in a message.”;
}else{
$comment = htmlentities($_POST[‘comment’]);
}

[/php]
in the first line the underscore was missing.

If(empty($POST[‘comment’])){

and this what should been.
[php]
If(empty($_POST[‘comment’])){
$errors[] = “Please enter in a message.”;
}else{
$comment = htmlentities($_POST[‘comment’]);
}

[/php]
know solved thank once helping me in trying to find the problem

I can’t believe I didn’t catch that!!

Good Work!

Sponsor our Newsletter | Privacy Policy | Terms of Service