FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Is this code good?





mtorregiani
Hi
I just found this code and I want to know if it is good, or if it has some troubles...

Code:

<?php

// Designate your username and password
$username = "user";
$password = "pass";

if ($_POST['user'] != $username || $_POST['pass'] != $password) {

?>

<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     <p><label for="user">Username:</label>

     <input type="text" title="Please enter your Username" name="user"></p>

     <p><label for="pass">Password:</label>

     <input type="password" title="Please enter your Password" name="pass"></p>

     <p><input type="submit" name="Submit" value="Login"></p>

</form>

<?php

}
else {

?>

<!-- Place the Password Protected content here -->

<p>Content.</p>

<?php

}

?>


Thanks
bladesage
It looks just fine from what I can tell.

I see no obvious flaws in it. It should work alright.
hexkid
mtorregiani wrote:
Hi
I just found this code and I want to know if it is good, or if it has some troubles...

Code:
...
<label for="user">Username:</label>
<input type="text" title="Please enter your Username" name="user">
...


The PHP part of it seems ok.
I have an HTML quirk for it though Smile

The label element specifies what other element it is a label for with the attribute for. But the value of the for attribute must be the same as the value of the id attribute of the associated control element, and you have no ids for your inputs!

You can simply code the labels without a for attribute and enclose the input within the label
Code:

<label>Username: <input type="text" title="Please enter your Username" name="user"></label>
mtorregiani
Thanks a lot.
Related topics
De da vinci code
add some media code in the forum
PHP: Directory listing code
Problam about google ad code
One Liners for Code Cowboys
Creating a new Operating System
Show PHP Code
Warcraft III - Frozen Throne ( Cheat code )
Security Code Graphic
very simple PHP code to get search query string
Programming Help & Support Guidelines
What's wrong with this C code???
html and css code from form inputs
[PhP] News Posting Tutorial (code, actually ^^')
What's your geek code?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.