#20714 [Opn->Bgs]: Error when accessing value of the textbox
| From: | derick@php.net | Date: | Fri, 29 Nov 2002 09:31:29 +0000 |
| Subject: | #20714 [Opn->Bgs]: Error when accessing value of the textbox | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-26154@lists.php.net to get a copy of this message | ||
ID: 20714
Updated by: derick@php.net
Reported By: manu_kalia@hotmail.com
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Windows 98
PHP Version: 4.2.3
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2002-11-29 03:21:22] manu_kalia@hotmail.com
Hi,
i have written a small .php file which has two input boxes and an
submit button. On the click of the submit button i am calling the same
php page again. The form action attribute has been set accordingly and
method has been set to "POST". when i open the page for the first time
i get an error saying
"Undefined index: txtUserName in C:\Inetpub\wwwroot\dataauth.php on
line 16"
But after the page is submitted the error does not come and i can see
the value which i had entered as specified by the echo command.
The code is as follows:
<html>
<body>
<form action="DataAuth.php" method="POST">
<table cellspacing=1 cellpadding=1>
<tr>
<td>User Name</td><td><input type="text"
name="txtUserName"></td>
</tr>
<tr>
<td>Password</td><td><input type="text"
name="txtPassword"></td>
</tr>
<tr><td> </td></tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
<?php echo $_POST["txtUserName"]; ?>
<?php echo $_POST["txtPassword"]; ?>
<?php
$auth = false; // Assume user is not authenticated
if (isset($PHP_AUTH_USER ) && isset($PHP_AUTH_PW))
{
$dbc = new COM("ADODB.Connection");
$dbc->Provider = "Microsoft.JET.OLEDB.4.0";
$dbc->Open("C:\Afrea Final\Data\RegAfrea.mdb");
$rs = $dbc->Execute("select Title,surname,Firstname from Registration
where surname='$PHP_AUTH_USER' AND firstname='$PHP_AUTH_PW'");
if ($rs->Recordcount==0)
{
$auth = false;
}
else
{
$auth = true;
}
$rs->Close();
}
if ( ! $auth ) {
header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
echo '<P>You are authorized!</P>';
}
?>
</form>
</body>
</html>
Can i know the reason why and how can i prevent this error from coming
when the page is displayed for the first time.
Thanks
Manu
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20714&edit=1