Garbage

December 2nd, 2009

This site becomes full of garbage now. I didn’t post from last 2/3 years. I didn’t even visit my site. By this time my site becomes hacked. I restored my site but i lost huge posts and comments. I am sorry to them who have posted valuable comments to my posts, i had no databse backup and thats why site becomes unstable now! Anyways, I am declaring this site as DEAD. I am not maintaining my site anymore and i am not even reviewing any comments.

I don’t know if i ever start writing here or not! I got disappointed for this occurrence. Thanks for your time.

AJAX file upload

September 22nd, 2006

Actually i didnt find the way to upload files with AJAX. And may be its not possible. Here i did a tricks by adding form attribute [ target=”addImageFrame” ] where addImageFrame is a dummy iframe’s ID. SO whenever this form is being submitted its actually tageting that iframe and the page becomes unchanged. Here i’m using AJAX only to track wheather the file is uploaded or not and if upload complete AJAX is just returning the file name and path.

Here when you’l test it you will see a progressbar on it. This is also fake actually. Its not the actual progressbar for uploading an images. When i’m sending request for images upload i’m setting that progress bar image and when i get the image path i’m removing that image. This is not the 100% accurate progressbar but its pretty well enough. I’l write about progressbar later.

Here is the Demo

Form Submit in different way

September 19th, 2006

Few days ago i was working on a pager script where i have to submit a form manually to send a page. But due to user requirements thats need to send in delay and i was about to use CRON job for that. But this time i was in deep problem to send that page. I was using CURL, fsockopen and many others way to submit the form but none of those works for unknown reason. It was really a funny problem but at least i solved that.

Here i want to discuss about the different way to submit a form.

Traditional Form Submit:
This is the most common form uses everywhere.

< form action="targetpage.php" name="myForm">
[form elements]
< input type="submit" value="send" name="send" />
< /form >

JavaScript Form Submit:

You can call a javascript function at any event for example onClick at button or OnChange at combo box and so on. And inside your javascript just write the line above.

document.myForm.submit();

CURL Form Submit:
This technique is rarely used in our application but we can submit any form using CURL just like normal form. Here is an example :

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url); // set the post-to url
curl_setopt ($ch, CURLOPT_HEADER, 1); // Header control
curl_setopt ($ch, CURLOPT_POST, 1); // tell it to make a POST, not a GET
curl_setopt ($ch, CURLOPT_POSTFIELDS, urlencode($queryString));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$response = curl_exec($ch);
curl_close ($ch);

FSOCKOPEN Form Submit:

This is also rarely used in our general application. For the Internet domain, it will open a TCP socket connection to hostname on port port. hostname may in this case be either a fully qualified domain name or an IP address. Here is a sample code:

$method =”GET” ; // POST or GET define here
$fp = fsockopen($host,80);
if ($method == ‘GET’)
$path .= ‘?’ . $data;
fputs($fp, “$method $path HTTP/1.1\n”);
fputs($fp, “Host: $host\n”);
fputs($fp, “Content-type: application/x-www-form-urlencoded\n”);
fputs($fp, “Content-length: ” . strlen($data) . “\n”);
fputs($fp, “User-Agent: MSIE\n”);
fputs($fp, “Connection: close\n\n”);
if ($method == ‘POST’)
fputs($fp, $data);

while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;

AJAX Form Submit:

At any AJAX application we frequently use such code.

var http_request = false;
url ="myformactionpage.php";
parameters ="field1=val1&field2=val2";
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
` http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}

http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);

Share your tought if you find any others way to submit a html form.

Enjoy PHPing......

Simple AJAX Application With Autosuggest / Autocomplete Feature

September 18th, 2006

Today I was just reviewing my previous works and i found a code that i worked for autocomplete feature. And when i was running that code it wasn’t working. It was using CAPXOUS AutoComplete. Then i started to fix that code and i was also searching for others related works and i found BNS’s work that is also a cool work. I download that code and start working on it and within a hour i made a simple AJAX application with insert, delete ,sorting and autocomplete features. Its not a such hard job but i like to put this example here.

Here is the simple AJAX works

CAPTCHA to Secure Web Forms

September 1st, 2006

CAPTCHA an acronym for “completely automated public Turing test to tell computers and humans apart “. CAPTCHA technology is used to prevent forums, polls, guestbooks, and blogs are some of the popular places where automated robots can be found submitting forms.

Web forms are always prone to attack by people who want to use it for their own purpose. There are various way to prevent such attract but the most effective and accurate way is using CAPTCHA.

CAPTCHA mainly generate a random created image that is displayed to the user. The image contains a phrase, that is only human readable and after the form submit it verify the human submission by matching the phrase.

This technique doesn’t ensure the 100% security. Some CAPTCHA are breakable for OCR attacks. And there are also others vulnerabilities, such as session re-use and cross-vhost file inclusion on shared servers.

However CAPTCHA can be a great way to limit the amount of successful, unwanted HTTP POST requests in your application. There are many open-source class and code for CAPTCHA. PEAR’S CAPTCHA is one of the best package.

Happy CAPTCHA-ing!!!!!

Congratulation to the Winner of coding contest June 2006

August 11th, 2006

We have announced the winner of phpResource coding contest Few days ago. Thanks to all participants for the monthly coding contest. Congratulation to the winner of our first monthly coding contest June 2006. We are expecting more participants here and we are also trying to manage more sponsors for the winners.

Here is our first phpResource Group Code Contest winners!

1. Mohamed BADR - 1 Full Year (12 issues) Subscription to php|architect Magazine’s Digital (PDF) Format

2. Ahsan Mani - 1 Free Printed Book - PHPEclipse: A User Guide from Packt Publishing

3. Aminul Islam - 1 Year of hosting with 25MB web space, 2 MySQL DBs and 1 subdomain

Congratulations to you all!! We hope to see more contributions from all of our members and any PHP programmers.Lets contribute here and keep up your good works.

Happy Friendship Day!!!!

August 6th, 2006

Friendship day is celebrated on August’s first Sunday, every year. It is a day to wish our friends and meet and have fun together ,so make the most of it! Every times we are meeting with new peoples and some of them are becomes friends and somes are lost from our minds.

We have a short life to live. In our life, we collect lot many impressions, and our experiences grow as we grow. Sometimes we wistfully look back and feel that something that happened should not have happened. But We cannot turn the clock back. How about becoming friends again. How about forgiving the old friend. How will it feel if you erase the memories of ill feelings towards him/her? You will feel cleansed. You will feel fresh and you will feel inspired.

And today i’m going to wish all of my frineds though they are still my friends or not!

I got the highest benifit from my friends and i lost my most valueable times in my life cos of friends, but today i dont want to hate them.

“A true friend is someone who knows the song in your heart, and can sing it back to you when you have forgotten the words.” phpResource Logo

Today I Picked up My Honours Certificate !!!

July 19th, 2006

After a long time I received my graduation certificate. I finished my Exam in June 2004 and got Result in October, 2004 and awarded for “The Best Student Award” in February 2006 . Finally I received my certificate today. It’s really a great feeling when I got that in my hand.

Today When Zaman Sir asked me if I want to go abroad or not. I answeared him “No”. I have some tasks to do here . I’ll complete Zend Certification within short time and I have some ideas which need to be implemented within short time. And I really don’t have time to think about abroad now. I wanna stay here as long as I can . I want to stay here although I don’t know if I can stay here for long or not.

Life is Strange!!

Javascript Flash Player detection and embed script

July 13th, 2006

Few days ago when i was validating a site for W3 Standard and i was fixing error one by one. I saw that the < object > tag doesnt support W3 standard . And i was in deep trouble to fix those problem . But at least i got a Javascript thats detect flash player and helps me from removing that bugs.

this is very easy to use and configure. You just have to include a JS file and put the following line :

[For the further help, you can view the raw javascript here.]

Javascript Code ::

------------------
var so = new SWFObject("movie.swf", "mymovie", "200", "100%", "7", "#336699");
so.addParam("quality", "low");
so.addParam("wmode", "transparent");
so.addParam("salign", "t");
so.write("flashcontent");
---------

Here You can find the details about it . http://blog.deconcept.com/swfobject/

I really loved it !!!!

Generate a random alphabetic word

July 8th, 2006

Many times we need to create a random word in variable length . Then it seems complex to us cos php’s Rand() function return only random numbers not alphabatic charecter . And after getting a post at phpResource i have discovered a simple function for this problem . here is the code .

——————————-

function rand_word($length)
{
$word = “”;
for(
$ix = 1; $ix <= $length; $ix++)
{
$word .= chr(rand(97, 122));
}
return($word);
}

————————-
All you need to call this function with the desired langth . Its soo simplee……..
Example : rand_word(5);