javascript

Javascript and PHP Interaction

Javascript and PHP Interaction

The difference between Javascript and PHP

Javascript is a client side language, meaning that it is processed by the browser not the server. PHP is a server side language, that is processed by the server and the result of the process is displayed by the browser. A typical page that includes both lnaguages will be processed in this order - a browser sends a request for a document to the server, the server will send the document to the PHP parser to process the PHP code, then sends the document to the browser which then processes the Javascript.

Transfer Values Between Pages

Transfer Values Between Pages using Javascript

(Written by: geeeet -> Visit Homepage)

With this little piece of code, it's possible to transfer values between pages, just like if you were using a serverside language, like php, jsp or asp.

HTML Code:

// This function extracts the values from the url
function getValues(){
var urlEnd = document.URL.indexOf('?');
var values = new Array();
var names;
 
if (urlEnd != -1){
var params = document.URL.substring(urlEnd+1, document.URL.length).split('&');

Form processing with PHP: part 4

Form Validation

Validating a form

You can perform form validation before a form is submitted via JavaScript or after the form is submitted via PHP.

I've actually already demonstrated simple validation using PHP in Form Processing with PHP: Part 1, with the input.php script. After the form is submitted, the script checks to see whether a variable does or does not exist.

PHP Code:

<?php
//check if submit button clicked and the input field isn't empty, print hello
if ($submit == "click" && $UserName !=""):
echo "Hello, $UserName";

PHP On-The-Fly

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.

Syndicate content