Tuesday, October 24, 2006

Picking Up a Coding Language

Now once you have familiar with dreamweaver and HTML , let us think about a Programming language. This programming language must communicate with server or may run on server to gain access the necessary data or manage some database activities.

We have variety of languages for this purpose
1. php
2. asp
3. jsp
4. asp .net
etc.

But I use PHP as my programming language.
Later I have done some works in asp also.

Now a days a new concept has come. Which is called AJAX ( Asynchronous JavaScript and XML). which is a little bit harder for new programmers.

So lets start with installing PHP.
Many servers on the web are still using PHP4, but on your system , i.e. on your own machine you can easily have PHP5.

Here is the download link for PHP5.

For using php you must have some web servers like Apache.





How to Install the Apache Web Server on Windows

Set up and configure a local server to test your Perl/PHP Scripts and Pages
How to Install the Apache Web Server on Windowsby Christopher Heng, thesitewizard.com
Even though my "live" websites, like thesitewizard.com, are located on third party web hosts, I maintain an

Apache web server on my Windows machine. Why?

I find it very inconvenient to have to go online just to test and debug my PHP scripts. If you write CGI and PHP scripts, you might be in the same boat.
Although I do have Apache and PHP installed in my Linux box, it is a real hassle to keep having to reboot in order to test my scripts, since I spend most of my time in Windows.
If you are facing a similar situation, or want to set up Apache in Windows for some other reason, you might find the information here useful.
Windows 95 Preliminaries

If you are using Windows 95 (whether the original release or OSR1, OSR2, 2.1 or 2.5), you will need to install Winsock 2 first. (Skip this section if you're using a later version of Windows).
Get both WS2SETUP.EXE (Winsock 2) and the Y2K fix for that (Y2KVDHCP.EXE) from the Windows 95 download page on Microsoft's website.
Go to the link for the Y2K fix for Winsock 2 and DUN 1.3 (or later) and follow it. It'll lead you to a page with both the fix as well as the complete Winsock 2 package.
Note that Winsock 2 requires you to have DCOM version 812 or higher installed. If you don't have that, download it (free of charge) from Microsoft and install it.
If, like me, you hate to install anything on your Windows machine that will affect the fragile balance it currently operates under, here are some (hopefully) reassuring news:
You do not have to install DUN 1.3 just to install Winsock 2. The two are separate. The Y2K fix listed above will not install any DUN 1.3 if you do not currently have it. (DUN 1.3 has been reported to cause problems on a number of Windows 95 machines.)
Winsock 2 can apparently be uninstalled, and your original Winsock 1.1 will be restored. Your old Winsock files are copied to C:\WINDOWS\WS2BAKUP together with a batch file named WS2BAKUP.BAT which can be used to restore your Winsock 1.1 if your upgrade fails for some reason.
Windows 95/98/ME Notes
If you are thinking of allowing others on the Internet to access your web server while it is running on Windows 95/98/ME, think again. The operating system is not secure, and opening your system to the world is asking for trouble.
If you really need to go "live", my suggestion is to install Linux into another partition (or disk) and read up on how to tightened your security and run your Apache server from there. Linux, by the way, is free. One way to obtain it is to download a set from RedHat.

Installing Apache

Precompiled executables, complete with a Setup program, of the Apache server are available from the Apache website.
Download and run it to get the server copied onto your machine.
During installation, a dialog box will appear asking you for your domain name and server name. Simply enter "localhost" for both. Enter whatever email address you wish for the email address field. The installer uses these values to create a default Apache configuration file for you. Choose also to install Apache with shortcuts to start it as a service for all users.

Under Windows XP, when you finish installing Apache, the installer will automatically start up the Apache service.
To stop it and only start it manually when you need to use it for testing, go to Control Panel -> Administrative Tools -> Services, look for the Apache service and double-click it.
From here you can stop the service and change the startup type to "Manual".
The Apache service will then terminate and only start when you return to this control panel applet to manually start it. This is useful if, like me, you're only using the server to test your scripts, and don't want the server running all the time. Note that you will have to restart the service every time you make a configuration change.
Under Windows 9x, the newer versions of Apache do not appear to create a shortcut in the Programs menu that allow you to start the Apache server.
Simply navigate to "c:\Program Files\Apache Group\Apache\" and double click on Apache.exe to start the server. To terminate the server, select "Close" from the window's system menu.

If you change your mind about the server name you chose when you installed Apache, you can always change it with your favourite text editor (such as Notepad from your Start menu Programs Accessories Notepad) by searching for and replacing the following line in the

"C:\Program Files\Apache Group\Apache\conf\httpd.conf" file.

ServerName localhost

If you want your server to handle Server Side Includes (SSI), use a text editor (like Notepad) to open

"C:\Program Files\Apache Group\Apache\conf\httpd.conf".

Search for "server-parsed HTML files" in the file, and add the following lines (or uncomment the example lines in the configuration file by removing the prefixed hash marks, "#").
AddType text/html .shtml
AddHandler server-parsed .shtml

If you want "index.shtml" to be your default start page for your directories, ie, if you want Apache to load "index.shtml" when you type "localhost" or "localhost/directory/", you will need to search for a line in your "httpd.conf" that begins with "DirectoryIndex" and modify it as follows:

DirectoryIndex index.shtml index.html

Apache will now look for index.shtml first when it is given a directory without a file name, and only try index.html if index.shtml is missing.
If you're using Internet Explorer 5 (and above), Opera or Mozilla (and presumably Netscape 6 and above which is based on Mozilla), you can test that you've properly installed and configured Apache by typing "localhost" or its IP address "127.0.0.1" into the location bar of the browser. You should see the default page installed by the Apache installer on your hard disk. It is located in "C:\Program Files\Apache Group\Apache\htdocs\". I have not been able to get earlier versions of IE and Netscape 4.73 to connect without the Dial-Up Networking dialog box popping up and insisting that I connect to my ISP (defeating the entire purpose of this exercise for me).

If you can't get your browser to connect to your local webserver, you can still test it by manually mimicking a browser.
Go to the Start menu and select "Run". A dialog box will appear.
Type "telnet localhost 80" (without the quotes) into the dialog box and click OK.
The Windows telnet program will start up. Go to the Terminal Preferences dialog box and make sure that the "Local echo" check box is selected (unless you are one of those who like to type blind).
Type "get / http/1.0" (without the quotes) into the telnet window followed by hitting the Enter key twice.
You will get a whole lot of text scrolling swiftly by. This is the default page installed by the Apache installer on your hard disk. If you can get this it means that you've successfully installed Apache.
Where to Go From Here?

The entire Apache manual set was installed on your machine in the "C:\Program Files\Apache Group\Apache\htdocs\manual\" subdirectory. Read it. This guide only covers installation. You (obviously) have to configure your server and learn where to put your documents and the like. If you'd like a hardcopy book on the Apache server, the one I used when I first started out was the O'Reilly book Apache The Definitive Guide. It's a bit weak on installation (which is why I wrote this), but it is helpful if you need to learn about configuring Apache and bone up on security issues.
If you need to install PHP support into your server, check out my article on How to Install and Configure PHP 4 to run with Apache on Windows.
If you wish to support Perl CGI scripts on your server, check out the article on How to Add Perl CGI Support to Your Apache Web Server on Windows.
Remember, this installation guide is designed for you to install Apache for private offline use. If your site is going "live", I suggest that you not only learn how to configure from the manuals but also brush up on security issues as well.



So lets install Php. For installing PHP for the first time I study an artice from

http://www.thesitewizard.com/archive/php4install.shtml

This artice is very much useful for the beginners.

Lets have a look at this article with the problems I faced and the solutions which will be helpful to the beginers.



Why Install PHP?
The usual reason why you would want to install PHP on your own computer is that it makes testing and debugging your PHP scripts very much easier. Instead of having to log onto your ISP just to upload and test a script, you can do it offline and fix any bugs before the script becomes "live".
Installing PHP on Windows
Here is the step by step procedure:

1. Download the PHP binaries
PHP is free and comes complete with the source code. If you are not interested in hacking the PHP source code, you can simply download the Windows binaries. Both the binaries and the source code can be found at the PHP website.
At the time I wrote this, the relevant PHP binary to download comes in a zip file. The Windows installer version does not include the binaries to run PHP as an Apache module.

2. Installing PHP
Installation is actually trivial.

a. Create a directory for PHP on your computer. For the purposes of this article, I will assume that you created "c:\php".
b. You don't need all the files provided in the archive, so unzip the PHP archive into a temporary location.
For example, if you're using Windows 95/98/ME,
one possible temporary place to extract the files is "c:\Windows\Temp".
All the PHP files will be extracted into a folder of its own, with a name based on the version of PHP you downloaded.
For example, if you downloaded php-4.2.3-Win32.zip and extracted it into "c:\Windows\Temp", there'll be a folder called "c:\Windows\Temp\php-4.2.3-Win32\" where the files can be found.

Copy the following files into
"c:\php": php.exe, php4ts.dll and php4apache.dll.
You can find php4apache.dll in the "sapi" subdirectory (eg, "c:\Windows\Temp\php-4.2.3-Win32\sapi\" in our above example).
php4apache.dll is for use with Apache 1.3.X. You will need to use php4apache2.dll if you're installing it for Apache 2.X. Note however that I have not tested the procedure on Apache 2.X, so you're on your own there. Furthermore, php.exe is not strictly needed if you don't ever want to run PHP as a CGI binary or from the command line. I keep it around for those situations where I want to run a PHP script from an MS-DOS prompt without having to fire up the Apache web server.
If you plan to load PHP extensions, you will need to copy the files in the "extensions" directory to "c:\php" (or a sub-folder in "c:\php") as well. Note, though, that MySQL support is now integrated into php and no longer needs an extension dll. Follow the instructions below to make sure that your installation of PHP works before you start dabbling with the installation of extensions.

3. Configuring PHP

Copy "php.ini-dist" from the extracted files into your Windows directory, typically "C:\Windows" on Windows 95/98/ME, and rename it to "php.ini".
Use an ASCII text editor (such as Notepad, which can be found in the Accessories folder of your Start menu) to open "php.ini".
You may need to make the following changes to the file, depending on your requirements:
Your SMTP Server If you want the mail() function to actually send out email when you test your own PHP scripts, search for the section of the file beginning with the line "[mail function]" (without the quotes). You should come across a section that looks something like the following:
[mail function]; For Win32 only.
SMTP = localhost;
For Win32 only.
sendmail_from = me@localhost.com
Change it to point to your SMTP server and email account. For example, if your SMTP server is "mail.yourisp.com" and your email address is youremail@somewhere-or-other.com,
change the code to:
[mail function]SMTP = mail.yourisp.com
sendmail_from = youremail@somewhere-or-other.com
Note that after you do this, when your script tries to use the mail() function, you will need to be connected to your ISP for the function to succeed. If you do not modify the above lines and attempt to use mail() in your script, the function will return a fail code, and display (or log) the error (depending on how you configure php.ini to handle errors).

NOTE : Actually it need not be modified if you do not want the mail working for you. It is useful in web Servers but for beginners it is not needed. So forgot this step if you are installing PHP on your machine for development purpose.

Global Variables If you need to run scripts written for versions of PHP earlier than 4.1, search for "register_globals" in php.ini, and change it to the following:
register_globals = On
If you leave it at its default of "Off" in PHP 4.2.X and above, you will need to access your form data variables and cookies using (for example)
$_REQUEST["variable_name"]
instead of directly as $variable_name.
This may break scripts written for earlier versions (pre-4.1) of PHP.

There are numerous other things that you can change in php.ini to make PHP work as you prefer. If your intention is for your local setup to mimic your web host's installation of PHP, you should of course find out how your host sets up their PHP and modify your php.ini accordingly. You can easily find out how your host has set up their php.ini by using the phpinfo() function (see later in this article).

4. Configure Your Apache Web Server
If you want PHP to work with your Apache server, you will need to modify your Apache configuration file to load it. Naturally, you will need to have already installed Apache on your machine and configured it. You can find instructions for installing and configuring Apache at http://www.thesitewizard.com/archive/apache.shtml.

Note that you do not need to have the Apache web server installed in order to test your scripts. You can simply run the interpreter (php.exe) on your scripts (just put your script as a command line argument to php.exe). I find it more convenient, however, to have the server installed, since the browser and server combination will take care of any setting of environment variables and the like which you would otherwise have to do manually. It's up to you, of course. The rest of this guide will assume you installed Apache and wish to configure it to use PHP.
There are two ways to configure Apache to use PHP4: one is to configure it to load the PHP interpreter as an Apache module. The other is to configure it to run the PHP interpreter as a CGI binary. This article will give instructions for both, but you should only implement one of them, either the module method or the CGI binary method. Unless you have a particular reason for running PHP as a CGI binary, you will probably want to load PHP as a module in Apache, since it runs more efficiently that way.
a. Running PHP as an Apache module

To configure Apache to load PHP as a module to parse your PHP scripts, use an ASCII text editor to open the Apache configuration file, "httpd.conf", typically found in
"c:\Program Files\Apache Group\Apache\conf\".
Search for the section of the file that has a series of commented out "LoadModule" statements. (Statements prefixed by the hash "#" sign are regarded as having been commented out.) Add the following line after all the LoadModule statements:
LoadModule php4_module "c:/php/php4apache.dll"

If you are using Apache 2.X, remember to use "c:/php/php4apache2.dll" instead of "c:/php/php4apache.dll".

Next, for Apache 1.3.X users, search for the block of "AddModule" statements. Add the following line after the last "AddModule" statement:

AddModule mod_php4.c

Don't worry that you can't find a "mod_php4.c" file anywhere on your system. That directive does not cause Apache to search for the file on your system. For the curious, it specifies the order in which the various modules are enabled by the Apache server.

If you're using Apache 2.X, you do not have to insert the AddModule directive. It's no longer needed in that version. Apache 2.X has its own internal method of determining the correct order of loading the modules.

Finally, search for "AddType" in the file, and add the following line after the last "AddType" statement:

AddType application/x-httpd-php .php

If you need to support other file types, like ".php3" and ".phtml", simply add them to the list, like this:

AddType application/x-httpd-php .php3AddType application/x-httpd-php .phtml

b. Running PHP as a CGI binary

If you've configured PHP to run as an Apache module, skip forward to the next section. This section is for people who want to (or need to) configure PHP to run as a CGI binary.

Search for the portion of your Apache configuration file which has the ScriptAlias section. Add the line below after the ScriptAlias for "cgi-bin".
Note that if you installed PHP elsewhere, such as "c:\Program Files\php\", you should substitute the appropriate path in place of "c:/php/" (for example, "c:/Program Files/php/").

ScriptAlias /php/ "c:/php/"

Apache needs to be configured for the PHP MIME type. Search for the "AddType" comment block explaining its use, and add the following line after it:

AddType application/x-httpd-php .php

As in the case of running PHP as an Apache module, you can add whatever extensions you want Apache to recognise as PHP scripts, such as:

AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml

Next, you will need to tell the server to execute the PHP executable each time it encounters a PHP script. Add the following somewhere in the file, such as after the comment block explaining "Action":

Action application/x-httpd-php "/php/php.exe"

Note: the "/php/" portion will be recognised as a ScriptAlias, a sort of macro which will be expanded to "c:/php/" (or "c:/Program Files/php/" if you installed PHP there) by Apache. In other words, don't put "c:/php/php.exe" or "c:/Program Files/php/php.exe" in that directive, put "/php/php.exe".

c. Configuring the Default Index Page

This section applies to all users, whether you are loading PHP as a module or running it as a CGI binary.
If you want to make your PHP script execute as the default page for a directory, you have to add another line to the "httpd.conf". Simply search for the line in the file that begins with a "DirectoryIndex" and add "index.php" to the list of files on that line. For example, if the line used to be:
DirectoryIndex index.html
change it to
DirectoryIndex index.php index.html

The next time you access "localhost" or "localhost/directory/" without a filename, Apache will deliver "index.php" if available, or "index.html" if "index.php" is not available.

5. Testing Your PHP Installation

Create a PHP file with the following line:


Save the file as "phpinfo.php" (or any other name that you fancy, but with the ".php" extension) into your Apache htdocs directory.
Next, restart your Apache server so that it can read the new configuration directives you placed into httpd.conf.
Open your browser, and access the file you just created by typing "localhost/phpinfo.php" into your browser's location bar.
You should see an entire pageful of information about your PHP setup. Congratulations - you have successfully installed PHP and configured Apache to work with it. You can also use this same file, phpinfo.php, to find out more about how your web host has set up his php.ini so that you can duplicate it on your local machine.
If for some reason it does not work, you can check to see whether your PHP setup or your Apache setup is causing the problem by simply running php on the file with a command line like "c:\php\php phpinfo.php" (without the quotes).

If invoking PHP from the command line causes a large HTML file with all the PHP configuration information to be displayed, then your PHP set up is fine. The problem probably lies with your Apache configuration. Follow closely my instructions on how to install and configure Apache in http://www.thesitewizard.com/archive/apache.shtml as well as check the instructions on configuring it for PHP given above.
Learning PHP
The complete PHP reference manual can be obtained from the php website. You can refer to it online or download the entire set of HTML files for reference offline. As its name implies, it is a reference manual only. For tutorials, check out the PHP tutorials at thesitewizard.com.
Have fun!

ubk

Starting Development

Hi everybody, a few days ago I started my career as a freelancer in my friend's company. I have some programming knowledge in c and c++ ( not so good) but I don't know anything about web related things. Or how to create a
1. web page
2. make it look better
3. make it dynamic

i.e. It can interact with the end user and save or display any data which is required to a destined database from where it can be fetched later.

For the 1st purpose,
what I did is nothing to tell abt, but what I learn is more important.

First you have to Download Macromedia dreamweaver 8 or any versions below it or above it.

I think when we have tools like dreamweaver why code HTML on hand. Ofcourse we are in the 21st century.

Now on ce you have downloaded it or get a copy of it do the following things
i. Install it on your machine. It is very simple. don't worry abt that.
While installation finishes it will ask you abt the view you want, i.e. The Designer View or The Coder View.

If you are a designer I have nothing to tell you as I am not a Designer.
So pick the Second one, i.e the coder view.
And start exploring Macromedia Dreamweaver 8. Do some HTML pages and run it by pressing F12.

Insert some tables , give it some data , put some headings , play with dreamweaver for a little while. The more you play the better you know dreamweaver. They have some tutorials

http://www.adobe.com/support/dreamweaver/tutorial_index.html
http://www.intranetjournal.com/articles/200002/dream_index.html
http://www.intranetjournal.com/articles/200002/dream_index.html

But I never read that so I can't tell you how much useful are those to a coder. Ofcourse it is useful for you if you are a steady learner but all the coders I know they want to learn things fast. So learn Dreamweaver by hand, I prefer.