Pages

FLAMES In PHP



<!-- Start of PHP Coding-->
<?php
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];

if(isset($value1) && isset($value2)) {
if($value1 == $value2){
$msg="Both are same names";exit;
}
else {
$flames = array(f,l,a,m,e,s);
for($i = 0; $i < strlen($value1); $i++) {
for($j = 0; $j < strlen($value2); $j++)
if($value1[$i] == $value2[$j]){
$value1[$i] = $value2[$j] = '/';
break;
}
}
$value1 = str_replace("/", "", $value1);
$value2 = str_replace("/", "", $value2);
$count = strlen($value1) + strlen($value2);
$flame = "flames";

while(strlen($flame)!= 1) {
$diff = $count%strlen($flame);
if($diff == 0){
$diff=strlen($flame)-1;
} else {
$diff--;
}
$flame[$diff] = "@";
list($f1,$f2)= preg_split("/@/",$flame);
$flame=$f2.$f1;
}
switch($flame){
case f:
$msg="You are now Friends";
break;
case l:
$msg="You are now Lovers";
break;
case a:
$msg="You are now Ancestors";
break;
case m:
$msg="You are now Married";
break;
case e:
$msg="You are now Enemy";
break;
case s:
$msg="You are now Sister";
break;
}
}
}
?>
<!-- End of PHP Coding-->
<html>
<head>
<title>FLAMES</title>
<style>
body
{
font-family:"Trebuchet MS";
margin-top:150px;

}

</style>
</head>
<body>
<p align="center" style="color:#060;">
<?php echo $msg; ?></p>
<form action="" method="post">
<table width="30%" height="204" border="0" align="center" cellpadding="0" cellspacing="0" style="background:#CCC;box-shadow: 0px 0px 4px 1px #CCC;">
<tr>
<th scope="col" colspan="2" bgcolor="#999999">Flames</th>
</tr>

<tr align="center">
<th scope="row">Enter Name 1</th>
<td><input type="text" name="value1" autocomplete="off" required style="padding:8px 0;width:200"></td>
</tr>
<tr align="center">
<th scope="row">Enter Name 2</th>
<td><input type="text" name="value2" autocomplete="off" required style="padding:8px 0;width:200"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="submit"></td>
</tr>
</table>

</form>
</body>
</html>