Re: How would you write this?

From: Date: Mon, 05 Dec 2005 01:39:14 +0000
Subject: Re: How would you write this?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-226850@lists.php.net to get a copy of this message
On Sun, 4 Dec 2005 11:44:12 -0800 Curt Zirzow <czirzow@gmail.com> 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

« previous php.general (#226850) next »