Re: How would you write this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 4 Dec 2005 11:44:12 -0800
Curt Zirzow <czirzow@xxxxxxxxx> wrote:

> <style>
>   .errored {
>     color: #FF0000;
>   }
> </style>
> <?php
>      $set_class = array(0 => '', 1 => 'errored');
>      define('SET_USERNAME', 0x01);
>      define('SET_PASSWORD', 0x02);
>      define('SET_ALL', SET_USERNAME & SET_PASSWORD);
>      $set = 0;
>      $username = "";
>      $password = "";
> 
>      if (isset($_POST['username'])) {
>          $username = trim($_POST['username']);
>          if (strlen($username) > 0) {
>              $set |= SET_USERNAME;
>          }       
>      }
> > ...
>      if (($set & SET_ALL) == SET_ALL) { 
>          echo "Logging in with: " . $username . ':' . $password;
>      } else {
>  ?>   
> <form action="login.php" method="post">
> <table> 
> <tr><td colspan="2">Login:</td></tr>
> <tr><td>Username:</td>
> <?php
>   $class = $set_class[ $set & SET_USERNAME ];
>   echo "<td class="$class">
>   echo "<input type=\"username\" name=\"username\" value=\"" . $username . "\"/>"; 
> > ...
> 
> It might be a bit overkill for such a simple thing.. but heck.. i
> was bored :)

Interesting. This gives me some ideas. I'm also happy to know I wasn't
too far off :->

Thanks,
Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux