php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20714 Error when accessing value of the textbox
Submitted: 2002-11-29 03:21 UTC Modified: 2002-11-29 03:31 UTC
From: manu_kalia at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.2.3 OS: Windows 98
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: manu_kalia at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-11-29 03:21 UTC] manu_kalia at hotmail dot 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>&nbsp;</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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-29 03:31 UTC] derick@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC