Nothing really wrong with the code, just different error reporting set.
But, as a couple of cents worth from someone that's learnt the hard way, it is
usually preferable to do something like
if (!isset($submit)){...} and handle the negative condition first. (Of course
this won't be the case if you know that the variable is set and could contain
a value of true (>0) or false (0).)

Tom

Jerry Nelson wrote:

> We have two developers that are just learning PHP.  Working with the
> following code I do not have any problems.  However, the other person gets
> the error :
> Warning: Undefined variable: submit in .....
>
> The code is :
> <?php
> if ($submit){
> //process form
>          $sql="insert into ascodes values('$ascode','$name', '$date',
> '$desc','$date')";
>          $result = $db->query($sql);
>          echo "Thank You, come again\n";
> }else{
>
> ?>
>
> <form method="POST" action="<?php echo $PHP_SELF ?>" >
>          Accounting Code: <input type="text" name="ascode"><br>
>          Your name: <input type="text" name="name"><br>
>          Todays Date: <input type="text" name="date"><br>
>          Description: <input type="text" name="desc"><br>
>          <input type=submit name="submit" value="insert record">
>          </form>
>
> <?php
> }
> ?>
>
> *---------*-----------*----------*---------*---------*---------*--------*
> Jerry Nelson
> Datanamics, Inc.
> 973-C Russell Ave
> Gaithersburg, MD 20879
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to