<?php
error_reporting
(E_ALL E_NOTICE);

if (!
$_POST['function']) $match false;

elseif (
$_POST['function'] == 'ereg')
{
  if (
ereg($_POST['regExp'], $_POST['input'])) $match true;
  else 
$match false;
}

elseif (
$_POST['function'] == 'preg')
{
  if (
preg_match($_POST['regExp'], $_POST['input'])) $match true;
  else 
$match false;
}

?>
<html>
<head>
<title>Testování regulárních výrazů</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>
<form name="test" method="post">
Funkce:<br />
<input type="radio" name="function" value="ereg" id="ereg" <?php
if (!$_POST['function'] OR $_POST['function'] == 'ereg') echo 'checked';
?>><label for="ereg">EReg</label><br />
<input type="radio" name="function" value="preg" id="preg"  <?php
if ($_POST['function'] == 'preg') echo 'checked';
?>><label for="preg">PReg_Match</label><br />
<label for="input">Testovaný řetězec</label><br />
<input type="text" name="input" id="input" size="60" value="<?php
echo $_POST['input']; 
?>"><br />
<label for="regExp">Regulární výraz</label><br />
<input type="text" name="regExp" id="regExp" size="60" value="<?php
echo $_POST['regExp']; 
?>"><br />
<input type="submit" value="Odeslat">
</form>
<?php
if ($match)
{
  echo 
'<p style="color: green">OK</p>';
}

else
{
  echo 
'<p style="color: red">NO</p>';
}

?>
</body>
</html>