Some help would be great here.
The following snippets work, but I am unable to figure out how to activate the error message "You did not select a name for editing".
Both of the other error codes work but if I input 'given' and 'family' and forget to select the relevant radio button, the error message doesn't work.
No other problems with the code.
<html>
<table>
<?php
// Query member data from the database
$query1 = mysql_query("SELECT userId FROM users WHERE managerId='".$recid."' AND userGroup='".$group2."' ORDER BY userId ASC");
while($row1 = mysql_fetch_array($query1))
{
$firstGroup .=$row1['userId']. ' <input type="radio" name="snames" value="'.$row1['userId'].'" /> ' . " <br /><br>";
}
?>
<form method="post" enctype="multipart/form-data" action="<?PHP echo $_SERVER["PHP_SELF"]; ?>">
<tr>
<td><?php echo $firstGroup;?></td>
<td><input type="text" name="given" value="" /><p>
<input type="text" name="family" value="" /><p>
<input type="submit" value="submit" name="Send Data"></form></td>
</tr>
</table>
</html
Here are the error messages and their activation method.
<?php
// Process the form if it is submitted
if ($_POST['snames']) {
$snames = $_POST['snames'];
$family = preg_replace("/[^A-Za-z0-9]/", ".", $_POST['family']);
$given = preg_replace("/[^A-Za-z0-9]/", ".", $_POST['given']);
//next section deals with error messaging
$errorMsg = "ERROR:";
if(!$snames) {
$errorMsg .= "--- You did not select a name for editing.";
}
else if(!$family)
{
$errorMsg .= "--- You did not enter a family name.";
}
else if(!$given)
{
$errorMsg .= "--- You did not enter a given name.";
}
else
{
exit();
}
}// close if post
echo $errorMsg;
?>