Undefined variable??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Czar
Forum Commoner
Posts: 58
Joined: Sun Dec 29, 2002 11:17 am

Undefined variable??

Post by Czar »

I get following error "Undefined variable:user" with small user auth code. Don't get it...

Example:
Welcome to login area, please login with your username and pasword.<p></center>
<form method=post action = <?php echo $_SERVER['PHP_SELF']; ?>
<div align="center"><b>Username</b>:
<input type="text" size=15 name="user">
<b>Pass</b>:
<input type="password" size="15" name="pass">
<input type="SUBMIT" name="send" value="Enter">
</div>
</FORM>
<p>
<?php
if ($user == "user" && $pass == "pass")
{
etc...
User avatar
riley
Forum Commoner
Posts: 45
Joined: Thu May 02, 2002 6:31 pm

Post by riley »

You can check if the variable is set before the form information and set it to some default value.

Code: Select all

If (!IsSet($user))$user = "";
Post Reply