Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
dropshippers
golfing products
dvd information
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


PHP Server to Client with No Refresh.



Although most of our companies work is template based design, the end result is always unique and adapts to each client's individual needs. The process of merging a client's content and style with our templates creates an opportunity to challenge ourselves and once again put our web design skills to the test.

Recently, I found myself in a situation where it was necessary to pass information in the form of GET data from a simple flash button to a server side scripting language- all without reloading the current page. A client was running several different flash animated banners ads via XML layer popup, underlining some of her most popular website products and online services. She needed a simple way to track the overall efficiency of her small ad campaign. Specifically, she needed to know which banners were being clicked on and which banners were simply annoying or inconsequential to her client base. She also needed to know which were the most popular browsers accessing these pages.

I'll try to describe what needed to happen with out getting too techie.

An XML layer popup would pop up, offering the end user with a two options. In option A, one could click on the popup. This would take them to wherever the popup was designed to take them. Option B was for the end user to close the popup, and that would simply hide the XML layer's visibility property. At first, it sounded easy. However, beyond the obvious functionality of options A and B, each option needed to open, write, and save to an external file all without refreshing the current page. After all, the last thing anyone wants to see after closing a popup is another page pop up.

Nevertheless server side scripting languages, like PHP, require a refresh of the page to pass information. Unlike JavaScript which handles its business on the client side of a client server system via your browser (the client), PHP scripts are server-side because they operate solely on the server; data is sent to via POST or GET The script is then parsed, and the new data is sent back to the browser if necessary.

Here's the solution. I created the following

<iframe>.
<IFRAME id="ifrMain" name="main" src="myscript.php" frameborder="0" width="0" height="0" scrolling="no" ></IFRAME>

Note that the SRC property is the location of our PHP script, which will be summoned later, to write and save to our external file. Notice our width and height properties are both set to zero.

I still submit the data to my PHP script, from within the flash banner popup with the help of ActionScript's cool little getURL() function:.

on(press){

GetURL("myscript.php?banner=this&action=close","main", "GET");

}

However because the target (main) was loaded inside our little hidden <iframe>, only the <iframe> refreshes. The user will not see a window refresh, the scrip will be parsed by PHP and everyone lived happily ever after…


About the Author

Dave Collado is a senior design consultant at www.Foamers.net , and freelance web designer since 1999. Foamers.net offers quality website templates template customization, flash templates, phpnuke themes, phpbb themes, osCommerce templates,SWiSH templates, web design tutorials, and many other website design and web hosting services.



Written by: David Collado

 



Here is our complete list of articles


Apache MySQL and PHP for Windows

Apache MySQL PHP for Windows

ASP CGI and PHP Scripts and Record Locking What Every Webmaster Needs To Know

Autoresponders With PHP

Bring Your Web Site to Life With PHP

Clickbank Security Using PHP

Create a Simple Effective PHP Form for Your Web Site

Creating Dynamic Website Content with PHP MySQL

Developing a Login System with PHP and MySQL

Developing State enabled Applications With PHP

For Automated Sites PHP and MySQL are A Perfect Match

Get PHP pages indexed in the Search engines

Getting your Visitors Details Using PHP

How PHP Can Help Save You Time And Mistakes

How to make a simple form mailer with PHP

HTACCESS Wrappers with PHP

Maguma has integrated support for the eBay Acellerator Toolkit for PHP PHP AT in their PHP IDE Maguma Workbench

Make a Search Engine For Your Website With PHP

Mastering Regular Expressions in PHP

More Autoresponders With PHP

MySQL Database Handling in PHP

ONLINE the eBay Accelerator Toolkit for PHP PHP AT for the PHP IDE Maguma Workbench is available

Password Protection and File Inclusion With PHP

Password Protection with PHP MySQL and Session Variables

PHP Account Activation

PHP and Cookies a Good Mix

PHP Auto surf Websites

PHP Databases

PHP Dynamic Content

PHP Email

PHP Encryption

PHP Error Pages

PHP Files

PHP Form Series Part 1 Validators Client side Validation

PHP General Scripting

PHP Image Gallery

PHP in the Command Line

PHP is 10 years old

PHP my favorite Server side Programming Technology

PHP On The Fly

PHP Pear Packages Why they are so important to php developers

PHP Redirect

PHP Scripts Dont Have to End in PHP

PHP Sessions / Cookies

PHP Templates

PHP User Login Authentication

PIM Team Case Study Creating Text Effects With PHP and GD

Protecting your HTML and PHP Source Code

Quick Intro to PHP Development

Serialize this Saving Objects in PHP

Simple Solution for Php Includes IFrames

Site Personalization With PHP

Some PHP functions you must know

Track Your Visitors Using PHP

Victoryvisions The PHP/Mysql Company Complete website development company



Books
 Sponsors


 Random Code
date and time example(date and time)
read the contents of an ini file(beginner)
Processor information(functions)
 Random Article
How to Implement CAPTCHA With PHP and GD

So, you have a submission form on your website and need to prevent spam by auto-submitters. The most common way to do this is to implement CAPTCHA - an image with a randomly generated string (quote from Wikipedia, free online enciclopedia: “A CAPTCHA is a type of challenge-response test used in computing to determine whether the user is human. "CAPTCHA" is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart", trademarked by Carnegie Mellon University.”)

Simple, quick and efficient PHP solution for implement CAPTCHA:

the advantage of this solution: it is easy to read symbols by human and automated captcha processor software, but hard to process the image by computer because common CAPTCHA processors can't understand which one of the outputted symbols it must ignore!

obviously you need PHP engine enabled for your webserver, for execute PHP scripts, and GD (PHP graphics library) for generate the image. Webserver, PHP and GD versions are no matter, the solution below is tested for Apache(Windows and Unix), IIS(Windows), PHP-4, PHP-5, GD, GD2

1) Make a PHP script (separate file captcha.php) which will generate the CAPTCHA image:
[?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function _generateRandom($length=6){
$_rand_src = array(
array(48,57) //digits
, array(97,122) //lowercase chars
// , array(65,90) //uppercase chars
);
srand ((double) microtime() * 1000000);
$random_string = "";
for($i=0;$i<$length;$i++){
$i1=rand(0,sizeof($_rand_src)-1);
$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
}
return $random_string;
}
$im = @imagecreatefromjpeg("captcha.jpg");
$rand = _generateRandom(3);
$_SESSION['captcha'] = $rand;
ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
Header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
ImageDestroy($im);
?]

2) Add the following line at the top of the page where you need to implement the CAPTCHA (there should not be any output before this line, except you use php functions ob_start() and ob_end_flush() to turn on output buffering):
[?php session_start(); ?]

3) Add the following line for check is CAPTCHA entered by visitor valid, before the line where you will proceed submitted message:
[?php if($_SESSION["captcha"]==$_POST["captcha"])
{
//CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
echo 'CAPTHCA is valid; proceed the message';
}
else {

echo 'CAPTHCA is not valid; ignore submission'; }?]

4) Finaly add the CAPTCHA to the form:
[img src="captcha.php" alt="captcha image"][input type="text" name="captcha" size="3" maxlength="3"]

P.S.
notice:
- the tags "[?" and "?]" in code samples above should be replaced to the "", you may download original article and code sample here: free download php captcha demo

- requirements: a webserver (windows or linux no matter) with PHP engine, with GD (graphic library) support, you may check your php settings with phpinfo() function

- you need some blank jpg image for use it as background for CAPTCHA string


how to implement a simple cms using PHP and MySQL
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.