September 2005
Monthly Archive
Tue 13 Sep 2005
Posted by Administrator under
SEO ,
Traffic AnalysisNo Comments
“Mirror mirror on the wall, who’s the fairest of them all?” I’m going to bet that it’s not you, um I mean, not your website. With all of the new websites popping up all over the place how do you know where you rank? How popular is your site compared to the next one?
In most cases it’s safe to say that we all want our website to be popular. Maybe it means our business will be more profitable or maybe it’s just good for the ego. Now there is a website that ranks the popularity of your website. The website is http://www.alexa.com.
Alexa.com is a blast to use and is one of those websites that is hard to leave. For starters, Alexa.com lists the most popular websites starting from the #1 position. It also lists the “Movers And Shakers”, which are websites that are rapidly gaining or loosing popularity on the web. Alexa.com is a great tool for discovering new websites to visit because you can see where everybody else is going. It’s fun, informative, and can be a good tool for comparing your website to the competition.
So how does Alexa.com work? In 1997 Alexa.com created a tool bar that tracked which websites people visited on the web. The tool bar was incorporated into early versions of NetScape and Internet Explorer. Today there are over 10 million Internet users who browse the Internet while using some form of the Alexa.com tool bar. These users are constantly generating statistics about their browsing habits. Alexa.com uses the data to create reports that outline the popularity of websites on the Internet.
So the next time you want to see how popular your website is, visit Alexa.com. Simply type in your website’s address (www.yoursite.com) into the “search the web” box and press go. It will send you to a page full of statistics showing you how popular your website is right now. Just remember that being popular isn’t the only important thing in life. There are good looks, money, and Monday Night Football too.
|
About The Author
Craig Neidel has worked for NetSource Communications Inc. for 6 years and has experience in web development, e-commerce solutions and web marketing. NetSource Communications creates custom e-commerce solutions and web applications. http://www.ntsource.com.
|
Tue 13 Sep 2005
Posted by Administrator under
Web Site PromotionNo Comments
I’m sure everybody has received an email from a company promising to get their website placed first on all the major search engines. Maybe some of you have even tried these services or may be thinking about it right now.
NetSource would like to say BE CAREFUL! Did you know that it is possible that some search engine optimization companies could actually do things to get your website banned from search engines? Plus, many search engine optimization companies will only get you listed for the short term and under keywords that are not really doing you any good.
Continue reading below to find out how NetSource helps clients achieve top placements in search engines the old fashion way – “we earn it”.
The Collins Law Firm (CollinsLaw.com) is a successful Law Firm dealing with Environmental Contamination Law, Personal Injury Law, Business Fraud, and Contract Law. They are located in Naperville, Illinois. The Collins Law Firm came to NetSource because they wanted to expand their successful firm by using the web to generate new leads. At the same time, they wanted to make sure that the marketing we did for them wasn’t going to hurt their professional image by using techniques like spam or bad banner advertising. So NetSource created a plan to get CollinsLaw.com placed higher in search engines by using content and design elements instead of quick fix techniques.
The first thing NetSource did was to interview the customer to find out exactly what types of leads or clients they were looking to attract. We asked The Collins Law Firm to give us the keywords or terms they thought people were using to find their services on-line. Next, Netsource used special tools to figure out exactly what the general population was searching for on the search engines. By having both pieces of information we could figure out if the terms that Collins Law Firm gave us were actually terms that people were searching for. Plus, we could determine all the variations of keywords that might attract the correct types of leads to Collins Law Firm. Now we knew how large the market was and what it would take to move up the ladder in the search engines.
Step two involved creating a marketing plan based on the information we gathered from step one. A plan like this might include making changes to existing web page content, adding new pages, using pay-per-click systems, and many other web marketing techniques. The plan was to target topics or keywords that were the easiest to secure first and then target the more difficult keywords later in the campaign. By following this approach a website will gain popularity for specific topics or keywords early in the campaign. This popularity will make it easier to get listed under more difficult keywords later. The process takes time because after each change a review is needed to determine how effective the changes were. Then, based off of the findings, future changes can be implemented until the desired results are reached.
Today, The Collins Law Firm is getting calls from new clients that have found their services on-line. Their website should be effective long-term with only a small amount of maintenance cost in the future. This process is effective because it truly forces a client to create a website that is content rich in the area(s) they are trying to target.
The importance of web marketing cannot be overlooked. Without the proper web marketing your website may not be worth the hosting costs you are paying for it. With the proper marketing you can generate sales and leads that make you wonder why you didn’t start earlier. We can tell you that experience and hard work are the most important factors to look for when choosing a web marketing company. Make sure you interview the web marketing company you are working with and even see how they are doing ranking their own site. A lot can be learned from a web marketing company who can’t even get top listings for themself.
|
About The Author
Craig Neidel has worked for NetSource Communications Inc. for 6 years and has experience in web development, e-commerce solutions and web marketing. NetSource Communications creates custom e-commerce solutions and web applications. http://www.ntsource.com.
|
Tue 13 Sep 2005
Posted by Administrator under
Design and LayoutNo Comments
Home Page
Home page should clearly indicate what the site is about. Provide top level navigation on the first page, your logo, and tell to the visitor what he can found on your web site. Your home page should be informative, and should call your visitor on action. Home page is the place where the visitor decides what he will do, click on some of your links, or leave the site. If you have a discount, or if you offer some free service in attempt to make a contact with potential customers, make sure to provide link to that service on your home page.
If you decide to implement flash intro on your first page, make sure to give the user possibility to skip the flash intro. The link “skip intro” should be outside of the flash, because you will force the visitor to wait until the Flash movie is loaded.
Navigation structure
Place the navigation on the place where the people are used too look for it. Don’t experiment with the navigation! I can’t stress enough this. Keep the navigation system same on ALL pages. Visitors are not ready to learn your site navigation system. Consistency is the most important thing here. You should focus your effort on building consistent rhythm across all pages of your site.
Font size
Your font size should be enough big so your text can be read without effort. There are many people who will not bother to read very small letters. Don’t loose your visitors because of font size. Optimal size seems to be 12-13 points. Visitors should be able to read your text easy, without any effort. Broke big chunks of texts in paragraphs and make them easy to follow.
Line Length
The length of a line of type should be comfortable to read. The optimal line length for printed materials seems to be about 10 to 12 words, or 60 to 70 characters. Somewhat shorter lines of about 40 to 50 characters may be more appropriate for larger displays. If the line is too long the reader must search for the beginning of it; if it is too short it will break up words or phrases awkwardly.
Creating emphasis
Creating emphasis is an important and integral part of designing and typesetting. Handled with taste and good judgment it can help direct and inform the reader. When these qualities are lacking, or someone feels that every word is important and must be emphasized in some way then your web page starts to look like a battlefield and becomes difficult to read!
Graphics
It’s well known that one picture worth more than million words. This rule applies on Internet too. Do your best to show clear, attractive photo of your product. If you offer a service, find a photo which will best describe him. However, be careful about file size. Don’t compress your photo to that level to not be clear, but also don’t leave the photo on full quality. That will make file size too big, and will increase download time.
Gif vs. JPEG
Less experienced web designers many times use wrong format to store their picture. Here are few guidelines which will help mistakes to be avoided. If your photo has small number of colors (less then 64) GIF will be better choice. Make sure however to reduce the palette size too. That is, if your image have10-15 colors only, reduce your palette on 16 or 32 colors.
Also, if your image contains text, GIF format should be your choice. JPEG use loosy compression method and will cause text and edges to become blurry.
If you are saving a photograph – save it as JPEG
JPEG images can contain over 32 million different colours. That is much more than the human eye can see.
If you want to incorporate large text into a photographic image, JPEG may be a good format to use. While the edges may still get blurred, danger of it becoming unreadable is slim. If you think your image is more important than the text, go ahead and use the JPEG format.
Speed
Do your best to reduce the download time. We live in a busy world and people are not will to wait long time. Try to reduce size of your graphics as much as possible without to destroy the image. Image must look good, but size (in KB) should be as small as possible.
Test before publishing
Do your homework, and do it well. Your visitors will not bother to send you an E-Mail that some of your links does not work or that some of your images does not appear. Even if someone do so, it is quite embarrassing. Perform spell and grammar checking. Remember that in many cases visitor will build his opinion about you or your company on base on your web site. When published, site should not contain any “under construction” or “coming soon” messages.
|
About The Author
Zoran Makrevski is founder and CEO of SEO.Goto.gr. Since 1998 has focused on E-Commerce and attempts to bring more traffic to the customer sites bring him in the SEO industry, and he is running his own company today. Search Engine Positioning Firm SEO.Goto.gr
|
Tue 13 Sep 2005
Posted by Administrator under
Design and Layout ,
HTMLNo Comments
What is CSS?
CSS is a simple file which controls the visual appearance of a Web page without compromising its structure. Using CSS we can control our font size, font color, link color and many other attributes on our web page. This will make our HTML code much more readable and the page size will be reduced.
Why to use it and how to use it properly
If you don’t use CSS on your web pages and you have many tables and content on them, chances are that your HTML file size will be quite big. Fact is that we live in a busy world, and people are not will to wait more than 5 seconds web page to load.
From the other side some web developers implement the CSS on wrong way. They write their CSS in HTML code of the page, like this:
<html>
<head>
<title>My Page</title>
<style>
A
{
font-family: Verdana;
font-size:8pt;
color:black;
text-decoration:none
}
</style>
…..
What is wrong with this technique? Well, imagine that you have site with more than 50 pages. One day, you decide that you want to change font color and colors of the links on your site. You will have to edit ALL the pages on your site, and do to that you will need time, because you place your CSS in your web page.
Better way is to save your visual attributes in separate, external CSS file, and to link that file with your page like this:
<html>
<head>
<title>My Page</title>
<link href="myStyle.css" rel="stylesheet" type="text/css">
….
Using this technique, you can change the look of your site within minutes, regardless of the number of pages, because your visual attributes are saved in ONE external CSS file. Edit that file, and you are done.
Benefits
Which are the benefits of using CSS? List is quite long and I will list here only the most important.
- Your web page will load faster
- Web page will become more search engine friendly
- You can change you site appearance within minutes
- You can write separate CSS file for handheld devices which will be called up instead of the regular CSS file
- You can forget about creating printer friendly version of your site using separate CSS file when user chooses to print the web page.
Avoiding standard HTML commands like:
<font color="#0000ff"><font size=2>Product</font></font></font>
will help us to reduce file size, but that is not the only benefit. Using CSS word product in this example will be moved more close on the top of the document. Search engine will pick up more content and less code.
Imagine that you have 3 columns table on your page. When you see the code, you will notice that first come code for your table, and after that it come your content. Positioning your 3 columns using CSS instead of standard inline elements:
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="381" height="150" valign="top" bgcolor="FFEDD4">
My Product
</td>
<td height="150" valign="top" bgcolor="FFEDD4">
…..
When CSS is used, your code might look like this:
<div id="leftcontent">
My Product
</div>
Again your code is much more clear, and your content is moved on the top of your document, making your HTML page search engine friendly, and reducing your file size.
Content is one of the most important factors in Search Engine Optimization, and you will benefit with removing the unnecessary code in your HTML and create search engine friendly web page.
Validate it
Browser war is far behind us. Reality is that most of the people today use Internet Explorer, but you should try to be on safe side and ensure that your CSS code is valid. Not all browsers interpret the CSS on same way. You can validate your CSS here: http://jigsaw.w3.org/css-validator/
|
About The Author
Zoran Makrevski is founder and CEO of SEO.Goto.gr. Since 1998 has focused on E-Commerce and attempts to bring more traffic to the customer sites bring him in the SEO industry, and he is running his own company today. Search Engine Positioning Firm SEO.Goto.gr
|
Tue 13 Sep 2005
Posted by Administrator under
HostingNo Comments
So you want to publish a web site do you? Welcome to the club. These days it seems that almost everyone has a web site of some kind, and thousands more continue to be launched every day. It’s challenging enough to design a site and fill it with interesting content, but when all is said and done another challenge still remains – where to host it?
A popular choice for newbie webmasters, and even experienced ones, is to secure a free hosting plan with a company such as Yahoo! Geocities, Tripod or Angelfire. While these are easy to setup and free of charge, they do have limitations. Most free hosts don’t offer all the nice features that paid hosts do such as FTP access, CGI-BIN, or your own personal domain name. Instead you’re stuck with minimal features and a generic URL such as www.freewebhost.com/marcswebsite. This somewhat limits your web site‘s potential. Most free hosts also require you to run banners or pop-up ads on your web site to make it worth their while – these banners and pop-ups can obstruct the view of your web page and ultimately annoy visitors and drive them away. Lastly, most free hosts have a daily bandwidth limit that is very small, so if you do get a lot of traffic you’ll most likely exceed the allotted bandwidth and your site will be temporarily disabled. Overall I would recommend free web hosts for people that are new to web hosting and want to get a feel for how it works. I’d also recommend them for web sites that are personal in nature (such as an online journal) as well as web sites that don’t plan to generate any revenue. Free web hosts are a great stepping stone to paid web hosts – I myself starting building web sites 4 years ago using free hosts, and today I run several high traffic web sites that are hosted on paid web hosting plans.
Now it’s time to get into the good stuff – paid web hosting. Web hosting companies that charge money for their services are plentiful on the Internet, and feature a wide array of hosting packages at various price points. First we begin with so called “budget” web hosts, who claim to offer you the world for only $1 per month. Having used numerous such companies I feel I must tell you to proceed with caution here, as these companies aren’t all that they are cracked up to be. Many claim to offer 24/7 e-mail support, which in my experience turned out to be 0/0 e-mail support. My e-mails were either never answered or answered a week after I sent them. Even when I got a response it was generic in nature and completely unhelpful. Also, expect frequent outages with these budget web hosts as they rarely even have their own web servers – often they are reselling space on someone else’s web servers over which they have no control. One budget web host I used went down unexpectedly for 6 days, and they didn‘t even bother to notify their customers. As a result, my web site was down for 6 days and I lost most of my visitors as well as my hard-earned search engine rankings. Lesson learned: if the reliability and success of your web site is important to you, budget web hosting might not be the answer. However, this is not to say that all budget web hosts are bad – 1dollarhosting.com is one of the leaders in the budget web hosting arena and has quite a good reputation.
The next type of paid web host is what I refer to as a “mid-range” web host, meaning that they offer prices and service that will satisfy the majority of web sites out there. Mid-range web hosts like PowWeb, Your-Site.com and iPowerWeb offer packages ranging from $5 to $8 per month and provide the tools that most webmasters will need to run a web site, such as: CGI-BIN, tons of e-mail addresses, FTP support, visitor statistics and more. These hosts do have monthly bandwidth limits, but the limits are quite high, and most web sites will never reach them. However, if your web site features hundreds of file downloads and gets decent traffic you may be shocked at how soon you’ll reach those bandwidth limits. When you do, your site may be temporarily shut down or you’ll have to pay bandwidth overage charges, which can get pricey. Overall though, mid-range web hosts will be satisfactory for 90% of the web sites out there, and generally offer excellent uptime/reliability. In fact, many web-based businesses are successfully run using a mid-range web host. However, as mentioned previously, web sites that offer large files for download or sites that get a huge amount of traffic may find that a mid-range host doesn’t quite suit their needs. These types of web sites may require “high-end” web hosting solutions, the next topic in our discussion.
High-end web hosts typically service web sites that are extremely popular, have a high amount of traffic, and/or require pretty much 100% uptime. Most businesses rely on high-end web hosts to host their web sites. Rackspace.com is an example of a well known high-end web hosting company. Pricing for high-end hosts varies, but typically runs from about $50 per month to several hundred dollars per month. Many high-end hosts give you your own dedicated server (which they support) that is reserved just for you and your web site. The mid-range hosts I discussed earlier typically host many different web sites on the same server – this is known as “shared” hosting. High-end web hosts offer stellar reliability, bandwidth, and just about every tool you’ll ever need to run a successful web site. Another feature that some high-end web hosts provide is “co-location” hosting. In this scenario, YOU configure and provide the web server, but you get to plug it into their data center/network. This can be very nice because their data center usually has a fiber-optic connection directly to the Internet, offering blazing bandwidth and stellar reliability. People who run web-based businesses or extremely popular, high traffic web sites are good candidates for high-end web hosting.
Hopefully this brief overview gives you a good picture of the various types of web hosts that exist, and which one might be right for you. When you begin your search for a web host, always keep in mind the old adage “You get what you pay for” because it really does hold true in this case. Before you make the commitment to host a web site be sure to take some time and analyze what you want out of the web site, and decide which factors are most important to its success. Answering these questions will get you many steps closer to choosing the web host that’s right for you.
Tue 13 Sep 2005
Posted by Administrator under
Design and Layout ,
PHPNo Comments
See how you can create graphic effects on text with PHP and GD – drop shadows, arcs, fonts and colors.
Problem
A-tec Signs and Sraphics Inc. launched a web site with the idea to sell decals online. To achieve better customers ineterest the website had to integrate online decal builder. The company is offering also decals for vehicles which brought some specific requirements to the builder like having the decal text turning arround 4 types of arcs.
Goals
- Provide users with preview area
- Allow visitors to choose font and color
- Allow adding drop shadow and selecting drop shadow color
- Allow turning the text into arcs
- Real Time calculating
Solution
Because of the need for increasing customers interest we had to think about not for perfect math formulas when showing the graphs in the preview area, but for the people who will look at them.
As we will reaveal below, there were few problems going arround human appreceptions for something ‘perfectly smooth’ and the matchematical perfect figures.
Methodology
We were going to extensively use PHP GD library for the text effects. It provided easy changing of fonts and colors, adding drop shawdows and rotating the texts.
We had also to create color palletes which to appear when user click and disappear when color is selected (You can personally try the decals creating here). Using hidden layers and javascript was supposed to do the work.
The main problem in this site was to create 4 types of arcs so when the user selects one of them the text is created arround imaginary arc (like in the vector graphical softwares). We were going to study Bezie’s formulas and create these arcs with its help.
Implementation
PIM Team Bulgaria had the task to build the full functional online decals builder with the following features:
- Decal background
Some users were supposed to have their decals placed on colored background. We had to allow the preview area to be painted in a selected background. First we created the image in temp folder:
// the name of destination image
$dest='decals/'.time().'.jpg';
//the background
imagefilledrectangle ( $im, 0, 0, 590, 60, $colors[$_POST['bcolors']]);
$colors array contains the available color which are stored by the administrator in the database.
Thus, when the visitor selects a background it is passed as parametter to imagefilledrectangle function.
- Font selection
Users should be able to select fonts for their future decals. Knowing that we can’t consider all the fonts will be available on all visitor’s computers we had to upload them on the web server directory.
We allowed the admin to manage the fonts, adding their names and uploading files in admin area.
The fonts in the select box came from the database. Selected font was passed in the call to imagettftext funtion which is drawing on the previously created image.
- Color Selections
The color selections had to be a palettes which appear when user clicks and disappear when color is selected. The palette had to look as a table with colors and these colors are also defined in the
admin area so they had to come dynamicly. We had to seed a static javascript function with dynamic content.
We created a PHP cycle which was taking the colors from the database and then creating a string for HTML table. This table is then passed to a javascript function which creates the palletes with the help of hidden layers:
function showTable(table)
{
mouseX = window.event.x + document.body.scrollLeft+25;
if(table=='background')
{
var content="";
var y=460;
}
if(table=='fonts')
{
var content="";
var y=690;
}
if(table=='shadows')
{
var content="";
var y=810;
}
document.getElementById('tabler').style.pixelLeft=mouseX;
document.getElementById('tabler').style.pixelTop=y;
document.getElementById('tabler').style.visibility='visible';
document.getElementById('tabler').innerHTML=content;
}
Of course, once the user select the desired color we had to hide the pallette:
function setColor(elid,color,fromid,shc)
{
document.getElementById(elid).value=color;
document.getElementById('tabler').style.visibility='hidden';
}
Thus we created nice palettes which appear and disappear on a single click and don’t take much space on the screen.
- Drop Shawdows
The decals offered has the ability to have a drop shadow added so we had to add this option to the online builder. PHP however didn’t offered a nice function for that. We created a procedure which draws the texts twice – once the original 100% saturated text and once the shadow with a percentage of the color and appropriate displacement. Of course the shadow was drawn on the image before the main text.
@imagettftext($img, 20, $gr[$i], $x+$dx, $ys[$i]+$dy, $scolors[$shadowcolor], "fonts/".$_POST['fonts'],$word[$i]);
- Arcs
The main problem came when we had to ‘rotate’ the texts thru arcs. First we created perfect Bezie funtion which to draw the curves and adjust the letter above them. But what a surprise – the curves looked perfect alone, but when we adjusted the letters above them they seemed rough.
After studying this problem we realised that the rough screen resolution and the disability to antialise the images wouldn’t allow us to create nice arcs. We were standing against insoluble problem.
We decided to create few arcs with a graphical software (CorelDraw) and to see what could be wrong.
We noticed that Corel’s curves were looking great after they are manually adjusted. However you can’t just leave the program to create perfect curves automaticly. A human eye was needed to judge when a curve looks right and when not.
We got a totally different direction. There wasn’t an universal function to help us. The solution we found was to ‘manually’ adjust each letter. We created a procedure with cases which were adjusting each letter on the appropriate place and with appropriate rotation depending on how long was the text. It worked!
We created 2 arrays for each arc type – one array with the positions and one array with the rotations.
The rest was simple:
if($arctype)
{
$start=(35-$l)/2;
if($start%2) $start+=1;
$gr=array_slice($gr,$start,$l);
$ys=array_slice($ys,$start,$l);
}
if(!$arctype)
{
$ys=array();
$gr=array();
//making the arrays
for($i=0;$i
You can go on the atec’s site and try the arcs we achieved (http://atecsigns.com/decal/step_1.php).
Results
Now A-tec Sings’s web builder creates perfect decals with graphs, calculates the price and allows you to add the decals to your shopping cart and chgeckout (the shopping cart software is also created by PIM Team Bulgaria).
The builder allows the visitor to create the desired decals with any color, dropped shadow, background and shape, to preview it and to calculate the cost for different sizes and quantities.
The website and builder were promoted with massive radio advertising company. At that time it was the only decal builder which allowed creating texts arround arcs.
Conclusions
- Use GD to create text effects
- Do not forget that you can create you own functions for what GD does not offer
- Do not always search for math perfect formulas. The graphical effects are intended to the human eye
- Load fonts in the server
- Use javascript and hidden layers to achieve great flexibility
Tue 13 Sep 2005
Posted by Administrator under
SEONo Comments
Three way linking and concerns.
For many years SEO experts were happy with two way linking or reciprocal linking but in due time researchers anticipated a change in Search Engine’s Algo.
Not before too late it happened and the value of reciprocal linking started decreasing, it can never die but was almost like a dead. Now only escape was one way link, and getting one way link was close to impossible, possible ways were
- Directories.
- Paid links.
- Provide info capable of fetching some links.
Nothing was as easy as reciprocal links, so all the community who were used to reciprocal links thought of an alternative. It is often termed as three way links.
My Site B (secondary site) links to your site X and let X link to my main site A.
B –> X
X –> A
Now if I take this as two, first
B –> X , mysite B is linking is your site X , it should be consider as one way link , so cashing the one way link points.
Again if I consider
X–> A , where your site X is linking to my main site A , also considered one way link in sight of google.
QUOTE
Always Google and other SEs have adjusted their algo according to SEO tricks and SEO tricks according to SEs algos.
Google’s probability of catching you is very less but not 0, google can catch you by pattern recognizing methods , almost all incoming links to A is given a link from site B, that’s the catching pattern. Its almost impossible to scan million of sites to check for such pattern , but then how Google reaches to site B, HOW?
How Google reaches to site B through site A
Through whois
If both sites have similar whois info, then B is reachable through site A reference.
Same C Class IP
If both the site has same C class IP (111.111.111.abc and 111.111.111.xyz is same C class IP) , Same C class IP often means same server, and many amateur SEO experts do this mistake.
Related Site Syndrome
If Page A is linking to Site X and to Site Y , similarly Page B, Page C , Page D … (some good number of pages) links to both the sites , then you do a G or Y search with related:http://Y.com, you will get Site X as related (even though X and Y may be extreme apart with theme) and similarly if you do G or Y search for related:http://X.com you will get related Site Y, thus Search engine can understand that Y and X are related.
This is not a proven theory , but a happening thing as manual checking is gearing up, once big mamma said precaution is always better than cure, be careful to enjoy the investment on your site.
Have fun linking!
Tue 6 Sep 2005
Posted by Administrator under
PHPNo Comments
Installment 1
Developing State-enabled Applications With PHP
When a user is browsing through a website and is surfing from one web page to another, sometimes the website needs to remember the actions (e.g. choices) performed by the user. For example, in a website that sells DVDs, the user typically browses through a list of DVDs and selects individual DVDs for check out at the end of the shopping session. The website needs to remember which DVDs the user has selected because the selected items needs to be presented again to the user when the user checks out. In other words, the website needs to remember the State – i.e. the selected items – of the user’s browsing activities.
However, HTTP is a Stateless protocol and is ill-equipped to handle States. A standard HTML website basically provides information to the user and a series of links that simply directs the user to other related web pages. This Stateless nature of HTTP allows the website to be replicated across many servers for load balancing purposes. A major drawback is that while browsing from one page to another, the website does not remember the State of the browsing session. This make interactivity almost impossible.
In order to increase interactivity, the developer can use the session handling features of PHP to augment the features of HTTP in order to remember the State of the browsing session. The are basically 2 ways PHP does this:
- Using cookies
- Using Sessions
The next installment discusses how to manage sessions using cookies…
Installment 2
Cookies
Cookies are used to store State-information in the browser. Browsers are allowed to keep up to 20 cookies for each domain and the values stored in the cookie cannot exceed 4 KB. If more than 20 cookies are created by the website, only the latest 20 are stored. Cookies are only suitable in instances that do not require complex session communications and are not favoured by some developers because of privacy issues. Furthermore, some users disable support for cookies at their browsers.
The following is a typical server-browser sequence of events that occur when a cookie is used:
- The server knows that it needs to remember the State of browsing session
- The server creates a cookie and uses the Set-Cookie header field in the HTTP response to pass the cookie to the browser
- The browser reads the cookie field in the HTTP response and stores the cookie
- This cookie information is passed along future browser-server communications and can be used in the PHP scripts as a variable
PHP provides a function called setcookie() to allow easy creation of cookies. The syntax for setcookie is:
int setcookie(string name, [string val], [int expiration_date], [string path], string domain, [int secure])
The parameters are:
- name – this is a mandatory parameter and is used subsequently to identify the cookie
- value – the value of the cookie – e.g. if the cookie is used to store the name of the user, the value parameter will store the actual name – e.g. John
- expiration_date – the lifetime of the cookie. After this date, the cookie expires and is unusable
- path – the path refers to the URL from which the cookie is valid and allowed
- domain – the domain the created the cookie and is allowed to read the contents of the cookie
- secure – specifies if the cookie can be sent only through a secure connection – e.g. SSL enable sessions
The following is an example that displays to the user how many times a specific web page has been displayed to the user. Copy the code below (both the php and the html) into a file with the .php extension and test it out.
[?php
//check if the $count variable has been associated with the count cookie
if (!isset($count)) {
$count = 0;
} else {
$count++;
}
setcookie("count", $count, time()+600, "/", "", 0);
?]
[html]
[head]
[title]Session Handling Using Cookies[/title]
[/head]
[body]
This page has been displayed: [?=$count ?] times.
[/body]
[/html]
The next installment discusses how to manage sessions using PHP session handling functions with cookies enabled…
Installment 3
PHP Session Handling – Cookies Enabled
Instead of storing session information at the browser through the use of cookies, the information can instead be stored at the server in session files. One session file is created and maintained for each user session. For example, if there are three concurrent users browsing the website, three session files will be created and maintained – one for each user. The session files are deleted if the session is explicitly closed by the PHP script or by a daemon garbage collection process provided by PHP. Good programming practice would call for sessions to be closed explicitly in the script.
The following is a typical server-browser sequence of events that occur when a PHP session handling is used:
- The server knows that it needs to remember the State of browsing session
- PHP generates a sssion ID and creates a session file to store future information as required by subsequent pages
- A cookie is generated wih the session ID at the browser
- This cookie that stores the session ID is transparently and automatically sent to the server for all subsequent requests to the server
The following PHP session-handling example accomplishes the same outcome as the previous cookie example. Copy the code below (both the php and the html) into a file with the .php extension and test it out.
[?php //starts a session session_start(); //informs PHP that count information needs to be remembered in the session file if (!session_is_registered("count")) { session_register("count"); $count = 0; } else { $count++; } $session_id = session_id(); ?] [html] [head] [title]PHP Session Handling – Cookie-Enabled[/title] [/head] [body] The current session id is: [?=$session_id ?] This page has been displayed: [?=$count ?] times. [/body] [/html]
A summary of the functions that PHP provides for session handling are:
- boolean start_session() – initializes a session
- string session_id([string id]) – either returns the current session id or specify the session id to be used when the session is created
- boolean session_register(mixed name [, mixed ...]) – registers variables to be stored in the session file. Each parameter passed in the function is a separate variable
- boolean session_is_registered(string variable_name) – checks if a variable has been previously registered to be stored in the session file
- session_unregister(string varriable_name) – unregisters a variable from the session file. Unregistered variables are no longer valid for reference in the session.
- session_unset() – unsets all session variables. It is important to note that all the variables remain registered.
- boolean session_destroy() – destroys the session. This is opposite of the start_session function.
The next installment discusses how to manage sessions using PHP session handling functions when cookies are disabled…
Installment 4
PHP Session Handling – Without Cookies
If cookies are disabled at the browser, the above example cannot work. This is because although the session file that stores all the variables is kept at the server, a cookie is still needed at the browser to store the session ID that is used to identify the session and its associated session file. The most common way around this would be to explicitly pass the session ID back to the server from the browser as a query parameter in the URL.
For example, the PHP script generates requests subsequent to the start_session call in the following format:
http://www.yourhost.com/yourphpfile.php?PHPSESSID=[actual session ID]
The following are excerpts that illustrate the discussion:
Manually building the URL:
$url = “http://www.yoursite.com/yourphppage.php?PHPSESSID=” . session_id();
[a href="[?=$url ?]“]Anchor Text[/a]
Building the URL using SID:
[a href="http://www.yoursite.com/yourphppage.php?[?=SID ?]“]Anchor Text[/a]
Tue 6 Sep 2005
Posted by Administrator under
MySQL ,
PHPNo Comments
Most interactive websites nowadays require data to be presented dynamically and interactively based on input from the user. For example, a customer may need to log into a retail website to check his purchasing history. In this instance, the website would have stored two types of data in order for the customer to perform the check – the customer’s personal login details; and the customer’s purchased items. This data can be stored in two types of storage – flat files or databases.
Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses:
- The inability to index the data. This makes it necessary to potentially read ALL the data sequentially. This is a major problem if there are a lot of records in the flat file because the time required to read the flat file is proportionate to the number of records in the flat file.
- The inability to efficiently control access by users to the data
- The inefficient storage of the data. In most cases, the data would not be encrypted or compressed as this would exacerbate the problem no. 1 above
The alternative which is, in my opinion, the only feasible method, is to store the data in a database. One of the most prevalent databases in use is MySQL. Data that is stored in a database can easily be indexed, managed and stored efficiently. Besides that, most databases also provide a suite of accompanying utilities that allow the database administrator to maintain the database – for example, backup and restore, etc.
Websites scripted using PHP are very well suited for the MySQL database as PHP has a custom and integrated MySQL module that communicates very efficiently with MySQL. PHP can also communicate with MySQL through the standard ODBC as MySQL is ODBC-compliant, However, this will not be as efficient as using the custom MySQL module for PHP.
The rest of this article is a tutorial on how to use PHP to:
- Connect to a MySQL database
- Execute standard SQL statements against the MySQL database
Starting a Session with MySQL
Before the PHP script can communicate with the database to query, insert or update the database, the PHP script will first need to connect to the MySQL server and specify which database in the MySQL server to operate on.
The mysql_connect() and mysql_select_db() functions are provided for this purpose. In order to connect to the MySQL server, the server name/address; a username; and a valid password is required. Once a connection is successful, the database needs to be specified.
The following 2 code excerpts illustrate how to perform the server connection and database selection:
@mysql_connect("[servername]", "[username]", "[password]") or die("Cannot connect to DB!");
@mysql_select_db("[databasename]") or die("Cannot select DB!");
The @ operator is used to suppress any error messages that mysql_connect() and mysql_select_db() functions may produce if an error occurred. The die() function is used to end the script execution and display a custom error message.
Executing SQL Statements against a MySQL database
Once the connection and database selection is successfully performed, the PHP script can now proceed to operate on the database using standard SQL statements. The mysql_query() function is used for executing standard SQL statements against the database. In the following example, the PHP script queries a table called tbl_login in the previously selected database to determine if a username/password pair provided by the user is valid.
Assumption:
The tbl_login table has 3 columns named login, password, last_logged_in. The last_logged_in column stores the time that the user last logged into the system.
// The $username and $passwd variable should rightly be set by the login form
// through the POST method. For the purpose of this example, we’re manually coding it.
$username = “john”;
$passwd = “mypassword”;
// We generate a SELECT SQL statement for execution.
$sql="SELECT * FROM tbl_login WHERE login = '".$username."' AND password = '".$passwd."'";
// Execute the SQL statement against the currently selected database.
// The results will be stored in the $r variable.
$r = mysql_query($sql);
// After the mysql_query() command executes, the $r variable is examined to
// determine of the mysql_query() was successfully executed.
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
// If everything went well, check if the query returned a result – i.e. if the username/password
// pair was found in the database. The mysql_affected_rows() function is used for this purpose.
// mysql_affected_rows() will return the number of rows in the database table that was affected
// by the last query
if(mysql_affected_rows()==0){
print "Username/password pair is invalid. Please try again.";
}
else {
// If successful, read out the last logged in time into a $last variable for display to the user
$row=mysql_fetch_array($r);
$last=$row["last_logged_in"];
print “Login successful. You last logged in at ”.$last.”.”;
}
The above example demonstrated how a SELECT SQL statement is executed against the selected database. The same method is used to execute other SQL statements (e.g. UPDATE, INSERT, DELETE, etc.) against the database using the mysql_query() and mysql_affected_rows() functions.
Tue 6 Sep 2005
Posted by Administrator under
Web Site CreationNo Comments
10 Basic Things Your Website Should Have …
__ all short sentences and paragraphs (more reader friendly)
__ lots of “white” space (more appealing)
__ graphics (makes site more interesting and entertaining)
__ links (widens reader interest)(boosts search engine ranking)
__ search engine listings (so people can find your site)
__ banner at top (makes home page look professional)
__ contact info (at least a valid email address)
__ About Me or About Us info (makes it more personal)
__ privacy policy (adds credibility; spam policy etc)
__ mission statement (defines ethics and purpose of your site). For more info go to http://thecooltool.tripod.com
With these 10 website basics your site can be both professional looking and appealing. And, as a result, you can expect to get a more positive response to your website and your website content.
|
About The Author
Maya Pinion is a Los Angeles based freelance writer and longtime webmaster, a dedicated googler, and loves visiting good websites.
|
« Previous Page — Next Page »