Abejali Technology

The Way To Success
Subscribe

Archive for the ‘PHP And AJAX’

PHP and Java Communication

November 03, 2008 By: abejali Category: PHP And AJAX 4 Comments →

<?php
/////////////////////////////////////////////////////////////////////////////////////////////
// Date : 03 November 2008
// Author : abejali
// Email : abejali@yahoo.com
// Title : Communicating Java Socket Server With PHP
//  This Function is to send parameter and get the result from java socket server
/////////////////////////////////////////////////////////////////////////////////////////////
function GetTCPResponse($Parameter){
/* Change to your Java Server Port */
$service_port =’208′; //getservbyname(’www’, ‘tcp’);
/* Get the IP address for the target host. */
$address =’127.0.0.1′; //gethostbyname(’www.example.com’);
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET,SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echosocket_create() failed: reason: ” . socket_strerror(socket_last_error()) . “<BR>“;
}
//echo “Attempting to connect to ‘$address’ on port ‘$service_port’…”;
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
echo socket_connect() failed.\nReason: ($result) ” . socket_strerror(socket_last_error($socket)) . “<BR>“;
}
$in = $Parameter;
$in .= chr(13) . chr(10); //End Of Java Transmission 
$out = ”;
$response =”;
//echo “Sending Data Transfer …”;
socket_write($socket, $in, strlen($in));
//echo “Reading response:\n\n<BR>”;
try {
while ($out = @socket_read($socket,2048, PHP_NORMAL_READ)) {
$response .= $out;
}
} catch (Exception $e) {
   echo Caught exception: ‘,  $e->getMessage(), “\n“;
}
//echo “<BR><BR>Closing socket…”;
socket_close($socket);
return $response;
}
// Test This Function
echo GetTCPResponse(”This Is My Test“);
?>

 


Using checkbox with PHP and AJAX

January 24, 2008 By: abejali Category: PHP And AJAX 19 Comments →

Download this script here

This is a sample for you to get some Idea on making multiple selections Script Using PHP and AJAX technology.

I have tried to find multiple selection script by using checkbox that is not directly been processed on submit form. There are too many examples outside but almost not exactly
what I want. So create by myself and I want to share it with you.

You can test the demo script here:



Get My Info


What Do You Want To Know About Me ?  
My Nick Name
My Favourite Movies
My Interest
My Full Time Job
The Answer Will Come Out Here:
:::


Since I have created this script using PHP 4, it supposed not to come out with any major problem with PHP 5++

If You Feel Lucky with this code, Why not just buy me some coffee :)


Manual Instruction:

  • Upload All Files into Your Server And Feel Good To Test And Modify.

Optional For PHP 5 User

  • Edit the file getinfo.php into PHP 5 code that I have commented inside the code

Download this script here

abejali.com