|
Hello All,
I am stumped as to why I am getting an Undefined index error from the following code:
<?php require 'lib.php';
$pw = isset($_REQUEST['pw']) ? stripslashes($_REQUEST['pw']) : "foo";
$pt = isset($_REQUEST['pt']) ? stripslashes($_REQUEST['pt']) : "foobar";
$encr = isset($_REQUEST['encr']) ? enc($_REQUEST['pt'], $pw, 256) : $_REQUEST['cipher'];
$decr = isset($_REQUEST['decr']) ? dec($_REQUEST['cipher'], $pw, 256) : stripslashes($_REQUEST['plain']);
?>
<form name="frm" id="frm" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<table>
<tr>
<td>Password:</td>
<td><input type="text" name="pw" size="16" value="<?php echo $pw ?>" /></td>
</tr>
<tr>
<td>Plaintext:</td>
<td><input type="text" name="pt" size="40" value="<?php echo $pt ?>" /></td>
</tr>
<tr>
<td><input type="submit" value="Encrypt it:" /></td>
<td><input type="text" name="cipher" size="80" value="<?php echo $encr ?>" /></td>
</tr>
<tr>
<td><input type="submit" value="Decrypt it:" /></td>
<td><input type="text" name="plain" size="40" value="<?php echo $decr ?>" /></td>
</tr>
</table>
</form>
I get the following:
PHP Notice: Undefined index: cipher in C:\Apache2.2\htdocs\php\test-php.php on line 12
PHP Notice: Undefined index: plain in C:\Apache2.2\htdocs\php\test-php.php on line 13
The problems occur with the $encr and $decr variables, I do have input text fields named "cipher" and "plain" so I do not understand why the error.
Thanks in advance for your help.
Cheers
|