WebsiteDays.com create your web site free, Hosting, Coding, E-commerce, Free Website Builder. Download free website builder to create your website! Personal, and ECommerce website builders...

WebsiteDays.com for france asnieres

Click on your region below to contact a Websitedays.com designer, or Websitedays.com sales person for info about Online Website builder system.

You can also send an email to

and we can forward your enquiry to respective designers in your area.

Agay Agen Aix-en-Provence
Aix-les-Bains Albertville Albi
Algajola Allevard Allinges
Allogny Ambert Amboise
Ambonnay Amiens Ammerschwihr
Ancenis Angers Angouleme
Annecy Annecy le Vieux Annemasse
Antibes Antony Apt
Arbois Archamps Archiac
Argeles-sur-Mer Argentat Argenteuil
Arlanc Arles Arpaillargues
Arras Ars-Laquenexy Artannes-sur-Indre
Asnieres Aubagne Aubervilliers
Aubiere Aubin Aubure
Aumont-Aubrac Auriac du Perigord Auribeau-sur-Siagne
Aurillac Aussois Auvillar
Avensan Avignon Avoriaz
Avranches Ax-les-Thermes Badefols-dAns
Bagneux Balaruc-les-Bains Bandol
Bar-Sur-Aube Barbizon Barcares Le
Barjac Barr Barre-de-Monts La
Baud Bayel Bayeux
Bayonne Baziege Bazoges-en-Pareds
Beaujeu Beaulieu-sur-Dordogne Beaumes-de-Venise
Beaune Beauvoir-sur-Mer Belfort
Belle-Ile-en-Mer Bellegarde sur Valserine Bellegarde-du-Razes
Bellevaux Bergerac Bergheim
Besancon Beynac Beynost
Beziers Bezouotte Biarritz
Bidart Biot Biron
Biscarrosse Blagnac Blere
Blois Boeschepe Bollene
Bondy Bonifacio Bons-en-Chablais
Bordeaux Bormes-les-Mimosas Boulogne
Boulogne-Billancourt Bourg-la-Reine Bourges
Bourgueil Brantome Bras
Brassac Brehemont Bresse La
Brest Breuil Le Brignoles
Brioude Brive Bugue Le
Buzet-sur-Baïse Cabanac Cabrieres-dAvignon
Caen Cagnes-sur-Mer Cagny
Cahors Calais Cambrai
Cambremer Camembert Cancale
Cannes Cantenac Cap-dAgde Le
Cap-dAil Carcassonne Carnac
Carnoux-en-Provence Carpentras Carquefou
Carros Cassis Castellane
Castelnau-de-Montmiral Castelsarrasin Castillon-la-Bataille
Cavaillon Cavalaire-sur-Mer Caylus
Cebazat Cerences Ceret
Cergy Cesson-Sevigne Cestas
Chablis Chalon-sur-Saone Chalons-en-Champagne
Chalus Chamalieres Chambery
Chambon-sur-Lignon Le Chamonix Champagne-Sur-Oise
Champagny-en-Vanoise Champigny-sur-Marne Champs-sur-Marne
Chaniers Chantilly Charolles
Chartres Chasseneuil Chateau-Chinon
Chateaubriant Chateaudun Chateauneuf-de-Gadagne
Chateauneuf-du-Pape Chateaurenard Chatel
Chatellerault Chatou Chaumont
Chenas Chennevieres-sur-Marne Chenoves
Cherbourg Cheylas Le Chigny-les-Roses
Chinon Civray Clairvaux-les-Lacs
Claix Clermont-Ferrand Clermont-lHerault
Clisson Cluny Cluses
Cognac Colle-sur-Loup La Collioure
Colmar Combloux Condom
Contamines-Montjoie Contrexville Corconne
Cordes-sur-Ceil Corte Cotignac
Coulaines Coulommiers Courbevoie
Courcelles de Touraine Courchevel Courneuve La
Cours-la-Ville Courseulles-sur-Mer Cramant
Cremieu Creon Creteil
Creutzwald Crillon le Brave Crolles
Cruet Cudos Curzay-sur-Vonne
Daglan Damery Deauville
Defense La Dieppe Dieulefit
Digne-les-Bains Dijon Dinan
Divonne-les-Bains Dizy Domevre-sur-Aviere
Douai Doue-la-Fontaine Draveil
Ducey Dunkerque Duras
Durtal Ecrosnes Ecueil
Ecully Epernay Epinal
Erbalunga Erstein Esperaza
Eugenie-les-Bains Evian Evreux
Evry Eze Faverges
Feilluns Felletin Ferrals-les-Montagnes
Ferte-Bernard La Foix Fondettes
Fontainebleau Fontcouverte-la-Toussuire Fontenay-sous-Bois
Forcalquier Foret Fouesnant La Forges
Fources Fourgs Les Fousseret Le
Frayssinet Frejus Furiani
Gaillac Galoubet Gap
Gardanne Garde La Garenne-Colombes La
Gassin Geispolsheim Genevraye La
Gennevilliers Gerardmer Geste
Gets Les Gevrey-Chambertin Ghisonaccia
Gif-sur-Yvette Giverny Golfe-Juan
Gordes Gramat Grand Pressigny
Grane Grasse Graulhet
Grenoble Guegon Gundershoffen
Haguenau Hardelot Havre Le
Haybes Heillecourt Herbiers Les
Hochfelden Hoerdt Honfleur
Hossegor Houilles Hourtin
Hyeres Ige Ile de Brehat
Illhaeusern Illzach Isle-sur-la-Sorgue
Issambres Les Issoire Issy-les-Moulineaux
Istres Jard-sur-Mer Jenlain
Joigny Jonvilliers Joue les Tours
Jouques Joyeuse Juan les Pins
LAigle Llle-Rousse La Bastide-Puylaurent
La Cadiere dAzur La Ciotat La Clusaz
La Ferte-Saint-Aubin La Grave La Madone
La Neuville-Aux-Larris La Rochelle La Rochepot
Labege Labruguiere Lacanau
Lagrave Lamalou-les-Bains Lamballe
Lambesc Lamotte-Beuvron Langeais
Langon Lanhelin Lapoutroie
Laudun-lArdoise Laurac-en-Vivarais Lauret
Laval Lege Lege-Cap-Ferret
Lens Les Houches Levallois-Perret
Ligre Lille Limeil-Brevannes
Limoges Lisle-sur-Tarn Loches
Locmariaquer Longueville Longwy
Lons-le-Saunier Lorcy Lorgues
Loudun Lourdes Lozanne
Luberon Ludon-Medoc Lunel
Lurais Luynes Lyon
Macon Mainxe Malakoff
Mandelieu la Napoule Manosque Mans Le
Marcq en Baroeul Margaux Marignane
Marlenheim Marnaz Marne-la-Vallee
Marseille Martel Massy
Matton-et-Clemency Maubourguet Maurepas
Mauroux Maussane les Alpilles Maylis
Megeve Meilhan-sur-Garonne Mende
Menerbes Menton Menuires Les
Mercurey Meribel Merignac
Messery Metz Meylan
Mieussy Miglos Mijoux
Millau Mirabel-aux-Baronnies Molsheim
Moncaret Monguilhem Mons-en-Baroeul
Montaigut-le-Blanc Montamel Montauroux
Montbrun-les-Bains Montceau-les-Mines Montelimar
Montfrin Montignac-Lascaux Montlhery
Montlouis-sur-Loire Montlucon Montmorillon
Montpellier Montreuil Seine-Saint-Denis Montreuil Pas-de-Calais
Morieres les Avignon Morlaix Morzine
Mougins Moustiers-Sainte-Marie Moux
Mouzillon Mulhouse Munster
Mur-de-Barrez Najac Nancy
Nanterre Nantes Narbonne
Nemours Neuf-Brisach Neufchateau
Neufchatel-en-Bray Neuilly-sur-Seine Neuvic
Neuville-en-Ferrain Nice Nimes
Niort Nissan-lez-Enserune Nogent-sur-Marne
Nolay Nuits Saint Georges Nyons
Obernai Olivet Oppede
Orange Orleans Orly
Orsay Orvault Osny
Ostwald Oullins Oyonnax
Paimpol Palaiseau Pamiers
Pantin Paris Parnac
Passy Pau Pauillac
Peisey-Nancroix Perpignan Pessac
Petite-Pierre La Peymeinade Peyrolles
Peyruis Peyzac-le-Moustier Pezenas
Pierrefeu-du-Var Pierrefitte-Nestalas Plagne La
Plazac Pleine-Fougeres Pleneuf-Val-Andre
Plombieres-les-Bains Plumaudan Poitiers
Pont Chateau Pont-de-Montvert Le Pontaumur
Pontgouin Pontivy Pontoise
Pontorson Port-Bail Port-de-Bouc
Port-Grimaud Portes-les-Valence Porto
Porto-Vecchio Pouilly-en-Auxois Prades
Premeaux-Prissey Propriano Puligny-Montrachet
Puteaux Quiberon Quillan
Quimper Rambouillet Ranton
Redorte La Reims Relecq-Kerhuon
Remaisnil Rennes Rennes-le-Chateau
Revel Ribeauville Riberac
Roanne Rocamadour Rocbaron
Roche-Bernard La Rochefort-en-Terre Rochefort-sur-Mer
Rognes Roissy-en-France Romaneche-Thorins
Ronchamp Roquebrune-Cap-Martin Roquebrune-sur-Argens
Roquefort-les-Pins Roscoff Roubaix
Rouen Rouffach Roujan
Roussillon Royat Rueil-Malmaison
Ruffec Rumilly Rungis
Ruoms Sables-dOlonne Les Sadirac
Saint Leons Saint Quentin en Yvelines Saint-Agreve
Saint-Amand-de-Coly Saint-Amans-Soult Saint-Aygulf
Saint-Barthelemy dAnjou Saint-Bauzeil Saint-Bertrand-de-Comminges
Saint-Bonnet-du-Gard Saint-Briac-sur-Mer Saint-Brieuc
Saint-Claude Saint-Cloud Saint-Cyr-en-Talmondais
Saint-Denis Saint-Disdier-en-Devoluy Saint-Emilion
Saint-Etienne Saint-Fargeau Saint-Florent
Saint-Flour Saint-Galmier Saint-Gaudens
Saint-Genis-de-Fontaines Saint-Germain-de-Belves Saint-Germain-en-Laye
Saint-Germain-sur-lArbresle Saint-Gervais Saint-Gervais-dAuvergne
Saint-Gilles Saint-Hilaire-de-Riez Saint-Hilaire-en-Lignieres
Saint-Jean-Cap-Ferrat Saint-Jean-de-Losne Saint-Jean-de-Maurienne
Saint-Jean-de-Sixt Saint-Jean-en-Royans Saint-Jean-Saverne
Saint-Jeannet Saint-Julien-en-Genevois Saint-Lary-Soulan
Saint-Laurent-de-Cerdans Saint-Laurent-du-Var Saint-Leu-la-Foret
Saint-Magne-de-Castillon Saint-Malo Saint-Mande
Saint-Martin-dArdeche Saint-Martin-de-Belleville Saint-Martin-Valmeroux
Saint-Matre Saint-Medard-en-Jalles Saint-Paul
Saint-Paul-de-Vence Saint-Paul-les-Trois-Chateaux Saint-Pons-de-Thomieres
Saint-Porchaire Saint-Quentin Saint-Raphael
Saint-Remy-de-Provence Saint-Romain Saint-Saturnin-les-Apt
Saint-Soupplets Saint-Victor-la-Coste Sainte Alvere
Sainte-Croix-du-Mont Sainte-Foy-la-Grande Sainte-Foy-Tarentaise
Sainte-Maure-de-Touraine Sainte-Maximin Saintes
Saisies Les Salignac-Eyvignes Sallanches
Salles-Curan Salon de Provence Salvagnac
Samoëns Sanary-sur-Mer Sancerre
Santenay Sarlat-la-Caneda Sarrians
Sartrouville Saugues Saulieu
Saumur Sausset-Les-Pins Sauvagnac
Saverne Savignac-les-eglises Scionzier
Seignelay Seillans Selestat
Semussac Senlis Sens
Serre-Chevalier Sete Sevres
Seyne-sur-Mer La Seyssuel Sezanne
Sierentz Sigy-le-Chatel Solenzara
Sophia Antipolis Soreze Sos
Soufflenheim Souillac Soulac-sur-Mer
Soulatge Soustons St Andre de Roquelongue
St Leon sur Vezere St Martin de Castillon St Tropez
St-Pierre-Quiberon St-Saens Strasbourg
Suevres Suresnes Tain-lHermitage
Taize Talence Talloires
Tarascon Tautavel Terraube
Thann Theoule-sur-Mer Thiers
Thieux Thor Le Thorens-Glieres
Tignes Tonneins Toul
Toulon Toulouse Touquet Le
Touquin Tours Tourtour
Treport Le Trinite-sur-Mer La Trouville
Troyes Turckheim Ulis Les
Uriage-les-bains Uzes Uztaritz
Val-dIsere Val-Thorens Valbonne
Valence Valflaunes Vallauris
Vallery Vallet Vallon-Pont-dArc
Vals-les-Bains Vannes Vanves
Varages Varenne-Saint-Hilaire La Vars
Vaucresson Vaulx-en-Velin Vauvert
Velizy-Villacoublay Vence Vendenheim
Venosc Vensat Ventabren
Ventron Vergisson Vergoncey
Vernon Versailles Verteillac
Vertus Vichy Villard-de-Lans
Villard-Reculas Ville Villefranche
Villefranche-de-Lauragais Villejuif Villemarechal
Villeneuve Villeneuve dAscq Villers-le-Lac
Villeurbanne Villie-Morgon Vincennes
Vinzelles Visan Vitry-sur-Seine
Vittel Voiron Vosne-Romanee
Vougeot Vouziers Voves
Wisembach

»   PHP On-The-Fly!

Article submitted in category: Web Design And Development
Tags: | php | example | javascript | new | page | /> | application | below | object | called | request objec

PHP On-The-Fly! by: Dennis Pallett

Introduction

PHP can be used for a lot of different things, and is one of the most powerful scripting languages available on the web. Not to mention it's extremely cheap and widely used. However, one thing that PHP is lacking, and in fact most scripting languages are, is a way to update pages in real-time, without having to reload a page or submit a form.

The internet wasn't made for this. The web browser closes the connection with the web server as soon as it has received all the data. This means that after this no more data can be exchanged. What if you want to do an update though? If you're building a PHP application (e.g. a high-quality content management system), then it'd be ideal if it worked almost like a native Windows/Linux application.

But that requires real-time updates. Something that isn't possible, or so you would think. A good example of an application that works in (almost) real-time is Google's GMail (http://gmail.google.com). Everything is JavaScript powered, and it's very powerful and dynamic. In fact, this is one of the biggest selling-points of GMail. What if you could have this in your own PHP websites as well? Guess what, I'm going to show you in this article.

How does it work?

If you want to execute a PHP script, you need to reload a page, submit a form, or something similar. Basically, a new connection to the server needs to be opened, and this means that the browser goes to a new page, losing the previous page. For a long while now, web developers have been using tricks to get around this, like using a 1x1 iframe, where a new PHP page is loaded, but this is far from ideal.

Now, there is a new way of executing a PHP script without having to reload the page. The basis behind this new way is a JavaScript component called the XML HTTP Request Object. See http://jibbering.com/2002/4/httprequest.html for more information about the component. It is supported in all major browsers (Internet Explorer 5.5+, Safari, Mozilla/Firefox and Opera 7.6+).

With this object and some custom JavaScript functions, you can create some rather impressive PHP applications. Let's look at a first example, which dynamically updates the date/time.

Example 1

First, copy the code below and save it in a file called 'script.js':

var xmlhttp=false;

/*@cc_on @*/

/*@if (@_jscript_version >= 5)

// JScript gives us Conditional compilation, we can cope with old IE versions.

// and security blocked creation of the objects.

try {

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

try {

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {

xmlhttp = false;

}

}

@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

xmlhttp = new XMLHttpRequest();

}

function loadFragmentInToElement(fragment_url, element_id) {

var element = document.getElementById(element_id);

element.innerHTML = '<em>Loading ...</em>';

xmlhttp.open("GET", fragment_url);

xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

element.innerHTML = xmlhttp.responseText;

}

}

xmlhttp.send(null);

}

Then copy the code below, and paste it in a file called 'server1.php':

<?php

echo date("l dS of F Y h:i:s A");

?>

And finally, copy the code below, and paste it in a file called 'client1.php'. Please note though that you need to edit the line that says 'http://www.yourdomain.com/server1.php' to the correct location of server1.php on your server.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">

<html>

<head>

<title>Example 1</title>

<script src="script.js" type="text/javascript"></script>

<script type="text/javascript">

function updatedate() {

loadFragmentInToElement('http://www.yourdomain.com/server1.php', 'currentdate');

}

</script>

</head>

<body>

The current date is <span id="currentdate"><?php echo date("l dS of F Y h:i:s A"); ?></span>.<br /><br />

<input type="button" value="Update date" OnClick="updatedate();" />

</body>

</html>

Now go to http://www.yourdomain.com/client1.php and click on the button that says 'Update date'. The date will update, without the page having to be reloaded. This is done with the XML HTTP Request object. This example can also be viewed online at http://www.phpit.net/demo/php%20on%20the%20fly/client1.php.

Example 2

Let's try a more advanced example. In the following example, the visitor can enter two numbers, and they are added up by PHP (and not by JavaScript). This shows the true power of PHP and the XML HTTP Request Object.

This example uses the same script.js as in the first example, so you don't need to create this again. First, copy the code below and paste it in a file called 'server2.php':

<?php

// Get numbers

$num1 = intval($_GET['num1'>);

$num2 = intval($_GET['num2'>);

// Return answer

echo ($num1 + $num2);

?>

And then, copy the code below, and paste it in a file called 'client2.php'. Please note though that you need to edit the line that says 'http://www.yourdomain.com/server2.php' to the correct location of server2.php on your server.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">

<html>

<head>

<title>Example 2</title>

<script src="script.js" type="text/javascript"></script>

<script type="text/javascript">

function calc() {

num1 = document.getElementById ('num1').value;

num2 = document.getElementById ('num2').value;

var element = document.getElementById('answer');

xmlhttp.open("GET", 'http://www.yourdomain.com/server2.php?num1=' + num1 + '&num2=' + num2);

xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

element.value = xmlhttp.responseText;

}

}

xmlhttp.send(null);

}

</script>

</head>

<body>

Use the below form to add up two numbers. The answer is calculated by a PHP script, and <em>not</em> with JavaScript. What's the advantage to this? You can execute server-side scripts (PHP) without having to refresh the page.<br /><br />

<input type="text" id="num1" size="3" /> + <input type="text" id="num2" size="3" /> = <input type="text" id="answer" size="5" />

<input type="button" value="Calculate!" OnClick="calc();" />

</body>

</html>

When you run this example, you can add up two numbers, using PHP and no reloading at all! If you can't get this example to work, then have a look on http://www.phpit.net/demo/php%20on%20the%20fly/client3.php to see the example online.

Any Disadvantages...?

There are only two real disadvantages to this system. First of all, anyone who has JavaScript turned off, or their browser doesn't support the XML HTTP Request Object will not be able to run it. This means you will have to make sure that there is a non-JavaScript version, or make sure all your visitors have JavaScript enabled (e.g. an Intranet application, where you can require JS).

Another disadvantage is the fact that it breaks bookmarks. People won't be able to bookmark your pages, if there is any dynamic content in there. But if you're creating a PHP application (and not a PHP website), then bookmarks are probably not very useful anyway.

Conclusion

As I've shown you, using two very simple examples, it is entirely possible to execute PHP scripts, without having to refresh the page. I suggest you read more about the XML HTTP Request Object (http://jibbering.com/2002/4/httprequest.html) and its capabilities.

The things you can do are limitless. For example, you could create an extremely neat paging system, that doesn't require reloading at all. Or you could create a GUI for your PHP application, which behaves exactly like Windows XP. Just think about it!

Be aware though that JavaScript must be enabled for this to work. Without JavaScript this will be completely useless. So make sure your visitors support JavaScript, or create a non-JavaScript version as well.

About The Author

Dennis Pallett is a young tech writer, with much experience in ASP, PHP and other web technologies. He enjoys writing, and has written several articles and tutorials. To find more of his work, look at his websites at http://www.phpit.net, http://www.aspit.net and http://www.ezfaqs.com

dennispallett@gmail.com

This article was posted on November 28, 2004