Jump to content

Recommended Posts

lots of reasons that could happen.  You could have upgraded to a new/diff php version that has error reporting set to show notices.  You could have added script somewhere that turns it on.  You could have deleted a var someone or reordered something to where that variable is not defined at that point in time (and error reporting set to that level).

 

It's just a notice, saying that the variable has not been declared.  You can make it go away be declaring it before using it, turning error reporting off on notices, or just ignoring it (because php allows you to use variables on the fly like that).

<form action="" method="post" name="login">

<link href="style1.css" rel="stylesheet" type="text/css">

<p><strong>Login</strong>

<br>Please enter your username and password to login to your account.</p>

<p><img src="images/line.gif" width="588" height="1"></p>

<!-- Check if fields are filled out -->

<!-- Check if fields are filled out -->
<?php 
extract($_REQUEST);
[b]line 9 ----[/b] if ($login == 'login')
{
echo '<div class="paddedtext" id="errorbox">';
/////////////////
extract($_POST);	
if ($username == '')
{
	echo 'Please enter your username.';
}else{
if ($password == '')
{
	echo 'Please enter your password.';
}else{
$dbhost = 'localhost';
$dbuser = 'whateva';

What do I edit in php.ini to fix this?

You can eliminate the errors by testing isset before you test if the variable is empty.

 

<?php
if (isset($variable) && $variable != '') {
// Do something.
}
?>

This way it tests if it's set...if it's not then it stops running. If it is set then it moves onto the next statement.

Checking if something == '' or != '' will throw an undefined error if the variable is not defined. That's why you should always test if it's set before anything else.

 

Edit: Also try putting a more descriptive title when posting in the forums.  It will increase the chances of getting help.

Edit Part 2: I also do not advise using extract on $_POST.

Do not ignore the errors, or turn them off (while developing), fix them, it will make you a better coder and make the code better.

 

All you need to do is make sure that all the variables are defined before using them.

 

E.g.

if(!isset($Var))

$Var = "";

Thanks a lot, have been checking if they are set, and this is solving the problem, just the hassle of doing it throughout the entire website.

Im not surprised if you have to do it to all variables judging by the code you posted above which I have quoted:

 

<?php 
extract($_REQUEST);
[b]line 9 ----[/b] if ($login == 'login')
{
echo '<div class="paddedtext" id="errorbox">';
/////////////////
extract($_POST);	
if ($username == '')
{
	echo 'Please enter your username.';
}else{
if ($password == '')
{
	echo 'Please enter your password.';
}else{
$dbhost = 'localhost';
$dbuser = 'whateva';

What do I edit in php.ini to fix this?

 

extracting all superglobal variables is just as bad as enabling register_globals. What so hard in typing $_POST['username'] over $username? Taking short cuts like this just causes more problems in the long run and can make your code vulnerable to attack.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.