Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Undefined index error
Old 06-07-2009, 03:10 AM PHP Undefined index error
Junior Talker

Posts: 2
Name: Jam One
Trades: 0
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
jamone is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-07-2009, 01:42 PM Re: PHP Undefined index error
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Its not an error its a notice. By default PHP won't report notices (the default value for error reporting in the php.ini is E_ALL & ~E_NOTICE). You are getting this message because you are looking up a key that doesn't exist.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 06-07-2009, 05:18 PM Re: PHP Undefined index error
Junior Talker

Posts: 2
Name: Jam One
Trades: 0
Well the code is not working. I get no html beyond the location of those warnings, and these are the only warnings in the code. What can be done to fix these warnings?
jamone is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Undefined index error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29896 seconds with 12 queries