Learn Hosting,WebDev,Scripting Make Money Hosting, WebDev,Scripting
Home :: HostScreamer.com
 
   

Developing A Login System With PHP And MySQL – Part 2

February 25th, 2007

Part 2 By John L

Component 3 – Forgot Password

A registered user may forget his password to log into the website’s system. In this case, the user will need to supply his loginid for the system to retrieve his password and send the password to the user’s registered email address.

This is typically done through a simple HTML form. This HTML form typically contains 1 field and 2 buttons:

1. A login id field
2. A Submit button
3. A Reset button

Assume that such a form is coded into a file named forgot.html. The following HTML code excerpt is a typical example. When the user has filled in all the fields, the forgot.php page is called when the user clicks on the Submit button.

[form name="forgot" method="post" action="forgot.php"]

[input name="login id" type="text" value="loginid" size="20"/][br]

[input type="submit" name="submit" value="submit"/]

[input type="reset" name="reset" value="reset"/] [/form]

The following code excerpt can be used as part of forgot.php to process the login request. It connects to the MySQL database and queries the table used to store the registration information.

@mysql_connect(”localhost”, “mysql_login”, “mysql_pwd”) or die(”Cannot connect to DB!”); @mysql_select_db(”tbl_login”) or die(”Cannot select DB!”); $sql=”SELECT password, email FROM login_tbl WHERE loginid=’”.$loginid.”’”; $r = mysql_query($sql); if(!$r) {

$err=mysql_error();

print $err;

exit(); } if(mysql_affected_rows()==0){

print “no such login in the system. please try again.”;

exit(); } else {

$row=mysql_fetch_array($r);

$password=$row["password"];

$email=$row["email"];

$subject=”your password”;

$header=”from:you@yourdomain.com”;

$content=”your password is “.$password;

mail($email, $subject, $row, $header);

print “An email containing the password has been sent to you”;

}

As in component 1, the code excerpt assumes that the MySQL table that is used to store the registration data is named tbl_login and contains 3 fields – the loginid, password and email fields. The value of the $loginid variable is passed from the form in forgot.html using the post method.

===============================================

Conclusion

The above example is to illustrate how a very basic login system can be implemented. The example can be enhanced to include password encryption and additional functionality – e.g. to allow users to edit their login information.

Used with the author’s permission.
This article is written by John L.
John L is the Webmaster of Designer Banners (http://www.designerbanners.com).

Article Source: http://EzineArticles.com/?expert=John_L




Linux Training-Running Linux to Get Real Experience

February 23rd, 2007

By Clyde Boom

You learn Linux best by getting real practical experience working with it. By using a Linux desktop, running Linux programs, and especially running Linux commands – the real power behind Linux administration.

5 Ways to Get Linux Running to Get Linux Training

1. Get Linux “pre-installed” on a new computer

This is one of the easiest ways to start working with Linux. Several major retailers now offer Linux pre-installed on their computer systems. Just buy it, boot it and start working!

2. Install Linux on a system that doesn’t have Windows

You can install Linux “from scratch”, from CD or DVD, on a new or used system that doesn’t already have an operating system (like Windows) on it.

3. Install Linux on a Windows system

If you don’t want to buy a new or used system for Linux, you can install Linux on an existing Windows system. When you do this, you create a “dual boot” (Linux and Windows) system.

After you install Linux and boot your system, a menu will appear allowing you to boot into Windows or boot into Linux!

In this case, you don’t need to buy a computer just for Linux. But there is a downside: if you make a mistake during the installation, or even if you delete Linux from your system later, you may loose all your Windows programs and data!

Linux Tip: Be sure to back up your system up before you install Linux and before you remove Linux.

4. Boot a system with a Linux “live” CD or DVD version

This one’s quite fun and very easy to do!

You can work with a Linux “live” version by booting a system with a Linux live CD or DVD.

Just put the Linux live CD / DVD in your drive and start your system. As soon as your system boots, Linux will automatically start and run “live”. No installation required!

Linux Tip: If you don’t have a high-speed connection to download Linux, you can buy Linux on CD or DVD and have it mailed to you anywhere in the world for a surprisingly small amount of money.

5. Run Linux from within Windows

A free “player” version of Linux is the easiest and fastest way to get Linux running from within Windows, on an existing Windows system!

Just run Windows and download and install the free Linux “player” program and a free “player” version of Linux. This lets you easily run Linux from within Windows!

Run the player program and open the player version of Linux and you get a fully functional version of Linux running from within Windows!

Now you know how to get Linux running so you can get real, practical experience working with Linux!

Clyde Boom, Author and Expert Trainer with 20+ Years of Training Successes. Explains intricate Linux technical matters in an easy-to-understand, non-technical manner, with tens of thousands of software and hardware learners into masters.

Watch Free Sample I Learn Linux Video Tutorials now at http://www.iLearnLinux.com and get over the steep Linux learning curve.

Sign up for Free I Learn Linux News to receive technical tips, info on new video samples and important updates on Linux.

You need to learn Linux the easy way to get that new job, qualify for that next promotion, earn a hefty raise, get Linux certification, or keep your current job because your company is trying to save on software licensing fees (eza). Watch, do, and learn Linux now!

Article Source: http://EzineArticles.com/?expert=Clyde_Boom