I am trying to demonstrate some encryption and decription. What i am trying to do is to match the input meaasages each character with the array. the new plain text character will be assinged to a variable called $newstr. The matching method is not working for me its gives me a parser error.
Code: Select all
<?php
if (isset($_POST['submit1']))
{
$str = $_POST['Customer_name'];
$key=array('A' => 'B', 'B' => 'C', 'C' => 'D','D'=>'E', 'E'=>'F', 'F'=>'G', 'G'=>'H', 'H'=>'I', 'I'=>'J', 'J'=>'K', 'K'=>'L','L'=>'M', 'M'=>'N', 'N'=>'O', 'O'=>'P', 'P'=>'Q','Q'=>'R', 'R'=> 'S', 'S'=>'T', 'T'=>'U', 'U'=>'V','V'=>'W','W'=>'X', 'X'=>'Y', 'Y'=>'Z', 'Z'='A');
$length=strlen($str);
$newstr=' ' ;
for ($i=0;$i<$length;++$i) {
//the each character of the message will be matched with the index value of the array.
if (preg_match($str, $key)) {
$str = $key[$i];
$str=$newstr;
echo"$newstr";}
/*if (in_array($str[$i],$key[$i])) {
$newstr.=$key[$i];*/
}
}
//this part is ok
echo"
<form action='pinassing.php' method='POST' >
<td>
<tr>
<td>
<font SIZE = 5 FACE = times new roman >Customer name</font>
</td>
<td>
<input type='text' name='Customer_name' maxlength='30'>
</td>
</tr>
</td>
<tr>
<td align='center' valign='top' colspan='2'>
<input type='submit' name='submit1' value='Confirm'>
</td>
</tr>
</form>";Shehan31