Hi Guys,
I am trying to call the Javascript function declared at the top in my php area. However its not working. Can anyone tell me the reason for it. Everything else is working except for this part. Please help me.
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AES (Rijndael) Encryption Test in JavaScript</title>
<script src="aes-enc.js" type="text/javascript" language="JavaScript"></script>
<script src="aes-dec.js" type="text/javascript" language="JavaScript"></script>
<script src="aes-test.js" type="text/javascript" language="JavaScript"></script>
<script type="text/javascript">
function doDecryption()
{
document.write("Inside Javascript");
var ct, key;
ct = hex2s(<?php echo $myValue; ?>);
document.write("Inside Javascript");
document.write(ct);
// key = hex2s(theForm.key.value);
// theForm.plaintext.value = byteArrayToHex(rijndaelDecrypt(ct, key, "ECB"));
}
</script>
</head>
<body>
<?php
mysql_connect("localhost","root","");
mysql_select_db("encryption") or die(mysql_error());
$userId = $_POST['userId'];
if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['key'] == ""))
{
$query = mysql_query("select * from employee_details where id = '$userId'");
if($row=mysql_fetch_assoc($query))
{
echo '<tr>';
foreach($row as $value)
echo '<td>'.$value.'</td>';
echo '</tr>';
}
else { echo "No rows returned"; }}
else if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['key']))
{
$columname = "ciphertext";
$tablename = "employee_details";
function getField($field, $tbl_name, $condition)
{
$result = mysql_query("SELECT $field FROM $tbl_name WHERE id = ".$condition);
return @mysql_result($result, 0);
}
$myValue = getField($columname,$tablename,$userId);
echo "$myValue";
[B]echo '<script type="text/javascript">
doDecryption();
</script>';[/B]
echo "whats happening";
//doDecryption();
}
?>
</body>
</html>