You are on page 1of 3

<?

php
include("formpage.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-
transitional.dtd">
<html>
<head>
<title>Table</title>
</head>
<body>
<?php
if(!isset($_POST['submitbutton']))
{
createForm();
}

else
{
$input1=isset($_POST['in1'])?$_POST['in1']:"";
$input2=isset($_POST['in2'])?$_POST['in2']:"";

$bug=false;
$error1="";
$error2="";

if(strlen($input1)<1)
{
$bug=true;
$error1=" textbox1 empty!";
}
if(strlen($input2)<1)
{
$bug=true;
$error2=" textbox2 empty!";
}
if($bug)
{
createForm($input1,$input2,$error1,$error2);
}

else
{
$tempchar="";
$tempcount="";

$holdarraychar=array();

$dumarraychar=array();
$dumarraycount=array();

if($_POST['in1']==$_POST['in2'])
{
?>
<center><div style="width:600px; height:50px;">
<p><font color="blue"><?php echo
"Character '".$_POST['in1']."' is added in the array."; ?></font></p>
</div></center>
<center><div >
<table width="500" border="1">
<?php
if($_POST['valholder']=="")
{
$tempchar=$_POST['in1'];
}
else if($_POST['valholder']!="")
{

$tempchar=$_POST['valholder']."-".$_POST['in1'];
}

?>
<center><div style="margin-top:10px;
width:600px;">
<table width="500" border="1">
<tr>
<td width="250"
border="1"><center><font color="blue">CHARACTER</font></center></td>
<td width="250"
border="1"><center><font color="blue">COUNT</font></center></td>
</tr>
</table>
<?php
$holdarraychar=explode('-',$tempchar);

$countarraychar=array_count_values($holdarraychar);

$dumarraychar=array_unique($holdarraychar);
?><table width="500" border="1">
<tr>
<td width="250" border="1"><?php
foreach($dumarraychar as $item1)
{

echo "<center><font
color='blue'>".$item1."</font></center>";

}
echo "</td>";
?><td width="250" border="1" ><?php
foreach($countarraychar as $item2)
{

echo "<center><font
color='blue'>".$item2."</font></center>";

}
echo "</td>";
echo "</tr>";

?>
</table>
</div></center>
<center><a href="iindex.php?valholder=<?php
echo $tempchar; ?>">Input another character</a></center>
<?php
}

else if($_POST['in1']!=$_POST['in2'])
{
?>
<center><div style="width:600px; height:50px;">
<p><font color="red">Inputed characters
are not equal.</font></p>
</div></center>
<?php
}
}
?><input type="hidden" name="valholder" value="<?php echo
$vhold; ?>" /><?php
}

?>
</body>
</html>

You might also like