Friday, March 15, 2013

For Automated Sites - PHP and MySQL Are A Perfect Match



You’ve decided to automate your web site. Now what? Here are some ideas to help you choose how to automate your site.

A bit of programming is going to be necessary if you want to automate a site. There are many types of programs that can be used to automate a web site including JavaScript, PHP, Perl, ASP, Java and more. So, which do you use? For many, it is a personal choice.

I prefer PHP for programming. PHP is a particularly useful programming language because it allows for advanced programming and is easy to integrate with web pages. Another plus of PHP is that the language interfaces very well with MySQL, a popular type of online database.

Yet another plus of PHP is that it is Open Source Code. The actual code that is PHP is available to the public for free, while the source code for products such as ASP are not. Because PHP is open source, there is a large community of PHP programmers that help each other with code. This means PHP programmers can rely on each other by using reusable pieces of code called functions and classes rather than constantly reinventing the wheel. This can dramatically cut down on production time.

Overall, PHP is flexible, cheaper than many alternatives, and built around a community. PHP and MySQL are excellent choice for webmasters looking to automate their web sites.

What Can PHP and MySQL do for me? Just about anything you can think of. That is the beauty of custom programming. A few ideas of what you can do with a PHP and MySQL driven site include:


  • E-commerce
  • User Polls
  • Keyword Tracking
  • Set User Preferences
  • Manage Password Protected Member's Areas
  • Lead Follow Up
  • Customer Relations
  • Content Management
  • Email Newsletters
  • Accounting
  • Invoicing
  • Scheduled Updates



The list is limited only by your imagination. Once you have decided to go with a PHP and MySQL site, you can either get a custom program created, use a prepackaged version or a combination of both. Many PHP and MySQL programs that come prepackaged are easy to customize and can save you a lot of time and money over starting from the ground up.

Zulkronz IT


Thursday, March 14, 2013

A login system with PHP and MySQL



Many interactive websites nowadays require a user to log in into the website's system to provide a customized experience for the user. Once the user has logged in, the website will be able to provide a presentation that is personalized to the user's preferences.

A basic login system typically contains 3 components which can be created using PHP and MySQL : 

Component 1: Allows registration of preferred login Id and password.

This is created in simple HTML form that contains 3 fields and 2 buttons: 

  •  A preferred login id field 
  • A preferred password field 
  • A valid email address field 
  • A Submit button 
  • A Reset button 


Lets say the form is coded into a file named register.html. The following HTML code extract is a typical example. When the user has filled in all the fields and clicks on the submit button, the register.php page is called for.

[form name="register" method="post" action="register.php"] 
  [input name="login id" type="text" value="loginid" size="20"/][br] 
  [input name="password" type="text" value="password" size="20"/][br] 
  [input name="email" type="text" value="email" size="50"/][br] 
  [input type="submit" name="submit" value="submit"/] 
  [input type="reset" name="reset" value="reset"/] 
[/form] 

The following code extract can also be used as part of register.php to process the registration. The code connects to the MySQL database and inserts a line of data into 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="INSERT INTO login_tbl (loginid, password and email) VALUES (".$loginid.",".$password.",".$email.")"; 
$r = mysql_query($sql); 
if(!$r) { 
  $err=mysql_error(); 
  print $err; 
  exit(); 

The code extract 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 values of the $loginid, $password and $email variables are passed in from the form in register.html using the post method. 


Component 2: Verification and authentication of the user.

In this the HTML form typically contains 2 fields and 2 buttons: 

  • A login id field 
  • A password field 
  • A Submit button 
  • A Reset button 


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

[form name="authenticate" method="post" action="authenticate.php"] 
  [input name="login id" type="text" value="loginid" size="20"/][br] 
  [input name="password" type="text" value="password" size="20"/][br] 
  [input type="submit" name="submit" value="submit"/] 
  [input type="reset" name="reset" value="reset"/] 
[/form] 

The following code extract can be used as part of authenticate.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 loginid FROM login_tbl WHERE loginid='".$loginid."' and password='".$password."'"; 
$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{ 
  print "successfully logged into system."; 
  //proceed to perform website's functionality - e.g. present information to the user 

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 values of the $loginid and $password variables are passed in from the form in authenticate.html using the post method. 


Component 3:  When the user forgets his logion password this 3rd component sends his password to the users registered email address. 

The HTML form typically contains 1 field and 2 buttons: 

  • A login id field 
  • A Submit button 
  • 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. 


This is how a basic login system can be created. The software developer can include additional tools like password encryption, access to the user profile in case they wish to edit their profile etc. 

This article has been compiled by the content development team at Pegasus InfoCorp which pulls subject matter specialists from different work domains. They can be contacted through the Pegasus InfoCorp website at info@pegasusinfocorp.com. Pegasus InfoCorp is an India based web design, web development and online/offline software development company. Please visit http://www.pegasusinfocorp.com to read more articles and know more about us!

Other companies and organizations are welcome to reprint this article on their websites provided the following conditions are met.
 The article is not changed in any manner 
 The article is copied as is in its entirety (including back links to the Pegasus InfoCorp website). 
 The company/ organization reprinting the article agrees to defend, indemnify and hold harmless Pegasus InfoCorp, its employees, directors, officers, agents, partners and their successors and assigns from and against any and all liabilities, damages, losses, costs and expenses, including attorney's fees, caused by or arising out of claims based upon the use of the article, including any claim of libel, defamation, violation of rights of privacy or publicity, loss of service by subscribers and infringement of intellectual property or other rights

Zulkronz IT

Wednesday, March 13, 2013

5 Basic Rules of Web Design


5 Basic Rules of Web Design the most important rule in web design is that your web site should be easy to read. What does this mean? You should choose your text and background colours very carefully. You don't want to use backgrounds that obscure your text or use colours that are hard to read. Dark-coloured text on a light-coloured background is easier to read than light-coloured text on a dark background. 

You also don't want to set your text size too small (hard to read) or too large (it will appear to shout at your visitors). All capitalised letters give the appearance of shouting at your visitors.

Keep the alignment of your main text to the left, not cantered. Centre-aligned text is best used in headlines. You want your visitors to be comfortable with what they are reading, and most text is left aligned.

Your web site should be easy to navigate

All of your hyperlinks should be clear to your visitors. Graphic images, such as buttons or tabs, should be clearly labelled and easy to read. Your web graphic designer should select the colours, backgrounds, textures, and special effects on your web graphics very carefully. It is more important that your navigational buttons and tabs be easy to read and understand than to have "flashy" effects. Link colours in your text should be familiar to your visitor (blue text usually indicates an unvisited link and purple or maroon text usually indicates a visited link), if possible. If you elect not to use the default colours, your text links should be emphasized in some other way (boldfaced, a larger font size, set between small vertical lines, or a combination of these). Text links should be unique - they should not look the same as any other text in your web pages. You do not want people clicking on your headings because they think the headings are links.

Your visitors should be able to find what they are looking for in your site within three clicks. If not, they are very likely to click off your site as quickly as they clicked on.

Your web site should be easy to find

How are your visitors finding you online? The myth, "If I build a web site, they will come," is still a commonly held belief among companies and organisations new to the Internet. People will not come to your web site unless you promote your site both online and offline.

Web sites are promoted online via search engines, directories, award sites, banner advertising, electronic magazines (e-zines) and links from other web sites. If you are not familiar with any of these online terms, then it is best that you have your site promoted by an online marketing professional. 

Web sites are promoted offline via the conventional advertising methods: print ads, radio, television, brochures, word-of-mouth, etc. Once you have created a web site, all of your company's printed materials including business cards, letterhead, envelopes, invoices, etc. should have your URL printed on them.

Not only should your web site be easy to find, but your contact information should be easy to find. People like to know that there is a person at the other end of a web site who can help them in the event that:
  • They need answers to questions which are not readily available on your web site;

  • Some element on your site is not working and end users need to be able to tell you about it, and 
  • Directory editors need you to modify parts of your site to be sure that your site is placed in the most relevant category.


By giving all relevant contact information (physical address, telephone numbers, fax numbers, and email address), you are also creating a sense of security for your end users. They can contact you in the way that makes them feel the most comfortable.

Your web page layout and design should be consistent throughout the site

Just as in any document formatted on a word processor or as in any brochure, newsletter, or newspaper formatted in a desktop publishing program, all graphic images and elements, typefaces, headings, and footers should remain consistent throughout your web site. Consistency and coherence in any document, whether it is a report or a set of web pages, project a professional image.

For example, if you use a drop shadow as a special effect in your bullet points, you should use drop shadows in all of your bullets. Link-colours should be consistent throughout your web pages. Typefaces and background colours, too, should remain the same throughout your site.

Colour-coded web pages, in particular, need this consistency. Typefaces, alignment in the main text and the headings, background effects, and the special effects on graphics should remain the same. Only the colours should change.

Your web site should be quick to download

Studies have indicated that visitors will quickly lose interest in your web site if the majority of a page does not download within 15 seconds. (Artists' pages should have a warning at the top of their pages.) Even web sites that are marketed to high-end users need to consider download times. Sometimes, getting to web sites such as Microsoft or Sun Microsystems is so difficult and time consuming that visitors will often try to access the sites during non-working hours from their homes. If your business does not have good brand name recognition, it is best to keep your download time as short as possible.

A good application of this rule is adding animation to your site. Sure, animation looks "cool" and does initially catch your eye, but animation graphics tend to be large files. Test the download time of your pages first. If the download time of your page is relatively short and the addition of animation does not unreasonably increase the download time of your page, then and ONLY then should animation be a consideration.

Finally, before you consider the personal preferences of your web page design, you should consider all of the above rules FIRST and adapt your personal preferences accordingly. The attitude "I don't like how it looks" should always be secondary to your web site's function. Which is more important: creative expression/corporate image or running a successful business?

Zulkronz IT