View Single Post
  #5 (permalink)  
Old 06-13-2007, 01:21 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Admin
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 442
iTrader: (0)
TeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to behold
Quote:
Originally Posted by Lee View Post
(i dont use id="" all that much, i use name="")
id is important to use if you want to use a scripting language like javascript to access information on the page through the DOM. name is important to use for submitting data as the value of name will be the new variable on the server when the form is submittted.

Now, let's look at

Code:
<form action="handlefile.php"> 
<input type="text" id="username">
</input>
<input type="submit" id="password">
</input> 
</form>
First, rewrite it as
Code:
<form action="login.php" method="post"> 
<input type="text" id="username" name="username" /><br />
<input type="password" id="password" name="password" /><br />
<input type="submit" value="Login" />
</form>
Then, assuming that form is also on login.php, you can access the username and password through $_POST['username'] and $_POST['password'], respectively. Here's an example.


PHP Code:
<?php
if (strlen($_POST['username']) > && strlen($_POST['password']) > 0) {
  
// verify username and password
 
if ($_POST['username'] == "allowed_username" && $_POST['password'] == "password") {
  
//Take login action
  
} else {
   
//Take invalid login action
  
}
}
?>
 <form action="login.php" method="post"> 
 <input type="text" id="username" name="username" /><br />
 <input type="password" id="password" name="password" /><br />
<input type="submit" value="Login" />
 </form>

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote