The way you have it now, would only work if parseComment
was the entered text for the input element, or the value from a checkbox, radio button, or select (I don't know what you have as a form element).
Because of this: if ($_POST['comType'] == "parseComment")
...which basically states: "If POST equals this text (or value), perform the operation.
Here is what I came up with to test my above-said, which will only test true if what seems to me would be the entered text "parseComment".
In the following example, it would return TRUE if $comtype = $_POST['comType'];
was indeed set in a variable.
A form has been included in my example, since none was included in your question, therefore it makes it that much more harder to know whether or not the form's element is named or not, and/or whether there was a typo/lettercase.
Sidenote: parseComment
and parsecomment
<= with a lowercase c
are not the same. So, if that is the case (no pun intended), then you need to double check everything.
<?php
if ($_POST['comType'] == "parseComment") {
$comtype = $_POST['comType'];
$name = $_POST['userName'];
$location = $_POST['userLocation'];
$comment = $_POST['userMsg'];
echo $comtype;
echo "<br>";
echo $name;
echo "<br>";
echo $location;
echo "<br>";
echo $comment;
echo "<hr>";
}
?>
<form action="" method="post">
ComType:
<input type="text" name="comType">
<br />
Username:
<input type="text" name="userName">
<br />
Location:
<input type="text" name="userLocation">
<br />
Comment:
<input type="text" name="userMsg">
<br />
<input type="submit" name="submit" value="Submit"><br />
</form>
A different method:
<?php
if ($_POST['comType'] == "parseComment") {
$comtype = $_POST['comType'];
$name = $_POST['userName'];
$location = $_POST['userLocation'];
$comment = $_POST['userMsg'];
echo $comtype;
echo "<br>";
echo $name;
echo "<br>";
echo $location;
echo "<br>";
echo $comment;
echo "<hr>";
}
if(empty($_POST['comType'])){
echo "ComType is either not set or is empty. Please enter a value.";
}
if ($_POST['comType'] !== "parseComment") { // check if NOT equal to
echo "That is not the comment I was looking for.";
}
?>
<form action="" method="post">
ComType:
<input type="text" name="comType">
<br />
Username:
<input type="text" name="userName">
<br />
Location:
<input type="text" name="userLocation">
<br />
Comment:
<input type="text" name="userMsg">
<br />
<input type="submit" name="submit" value="Submit"><br />
</form>