Tampilkan postingan dengan label Web Programming. Tampilkan semua postingan
Tampilkan postingan dengan label Web Programming. Tampilkan semua postingan

Make Simple Polling

11.09.2008
Creating a poll or a poll with a simple code html, php and javascript. To type the code can use Notepad program.

Save the following code with the name poll.js:

var xmlHttp

function getVote(int)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert (”Browser does not support HTTP Request”)
return
}
var url=”poll_vote.php”
url=url+”?vote=”+int
url=url+”&sid=”+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open(”GET”,url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState==”complete”)
{
document.getElementById(”poll”).
innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject(”Microsoft.XMLHTTP”)
}
return objXMLHttp
}
Save the following code with the name poll_form.html code, view this as the first page:








Silahkan pilih kesukaan anda :


Pilihan 1

Pilihan 2

Pilihan 3





Save the following code with the name poll_vote.php, this code to display the results of the voice that appear after we choose one of the options on the first page (the page poll_form.html):
$vote = $_REQUEST['vote'];

//get content of textfile
$filename = “poll_result.txt”;
$content = file($filename);

//put content in array
$array = explode(”||”, $content[0]);
$vote1 = $array[0];
$vote2 = $array[1];
$vote3 = $array[2];

if ($vote == 0)
{
$vote1 = $vote1 + 1;
}
if ($vote == 1)
{
$vote2 = $vote2 + 1;
}
if ($vote == 2)
{
$vote3 = $vote3 + 1;
}

//insert votes to txt file
$insertvote = $vote1.”||”.$vote2.”||”.$vote3;
$fp = fopen($filename,”w”);
fputs($fp,$insertvote);
fclose($fp);
?>






















Hasil:
Pilihan 1
’ height=’10′>
%
Pilihan 2
’ height=’10′>
%
Pilihan 3
’ height=’10′>
%
Total Suara:

Once the code is written above, save the third file the same location. You can do so locally or try the web hosting that you have. Open the file poll_form.html as the main page of a poll or a poll by your browser. The results of a poll or polls will be stored in the form of a text file as follows: 6 | | 0 | | 0.
You can modify the option to add a poll or a poll, the file poll_form.html and poll_vote.php (see the pattern, adding options such as Options 3
Source: modification of w3schools.com/php /

Basic - Basic Web

11.01.2008
Basic concept of the Web
Nowadays the development of web technology has so rapidly and has become a secret
public that using the website various types of information we can get.
The World Wide Web (WWW) is a repository (or storage warehouse) online in large-scale provide information. Service provided by a protocol that called HTTP (hypertext Transfer Protocol).
As though now the term "WWW" always is not with the term "Internet".
The Internet has its own understanding is a global network formed from
thousands and even millions more computers, or also called network of networks( network of networks).

technically, the web consists of 2 parts :
1. Web Server
Namely a computer and software that store and distribute data to the client computer through the internet ask (request) information. As an example of the software webserver including Apache, IIS, server Japache etc..
According to a survey conducted by www.netcraft.com that more than 50% of the world using the web Apache this is related to stability and the power of the web server.

2. Web Browser
That or a software program The application to operate process requests from the server and
so it can display information accessible. Examples of the IE browser, Mozilla Firefox, Netscape Navigator.

Client Side Programming
Basically, for the client side programming is the script / programming translated on the client. This means the script will be delivered directly to your browser without the client must be translated itself by the webserver. And the scripts are translated by the browser itself, this is of course related to the ability of the browser translate in a language programming. So, for example, when you to access the page with website using two browser certainly a different time will be
differences in views, this is because each browser has the ability certainly different to one another. Many of the client side programming Javascript is commonly known, Jscript,
VBScript, and others. The Pros and the lack of the client side programming are:
1. Speed transfer of data more quickly
2. Security less secure, because the script can be open or read View the source with facilities in
browser.

Server Side Programming
Server side programming is in the script that translates on the side server. For example, if you make program, the program will running on the server. And the results of execution will be sent to the client.
For example:
You access the page
http://www.gunadarma.ac.id/cgi-bin/script.cgi
then you have to use them after the URL
(Uniform Resource Locator) over the broswser will send the web demand (request) to the webserver The contents request that the client can to access the page CGI (common Gateway Interface), so that the client receive results from the server-side execution These programming. Many of the server side The script for the currently popular among them is the CGI, PHP, ASP, and JSP.
The Pros and the lack of Server side programming are:
1. Security script is intact, because the results of execution sent to the client.
2. Make the application site more dynamic and interactive.
3. The transfer of data longer, because only the results of the execution server sent to the client. But for now These shortcomings can be overcome with an increase in computer performance
and communication network that is more well.

Software Web Server
At this time there is some webserver has been among the Apache webserver, IIS, Tomcat, ColdFusion. And now the web is packed with some other software packages are apache2triad, PHPTriad, Xitami, MySql, LAMPP.
The installation process for the webserver itself must also be taken aspects aspects such as security, configuration aspects so that the server performance webserver that good.
Apache web server is the most many used on the Internet. This program first operating system designed for UNIX environment. However, the some of the next version of Apache removing programs that can run on Windows NT.
Apache name is taken from the words "A Patchy Server ", a server full of repair patches (patch). Patches is is adding features and bug penambalan from the NCSA httpd version 1.3.