Home arrow PHP arrow Page 3 - Building a Form to Count Back Links Using Yahoo Inbound Links API

PHP Script Preliminary Form Processing - PHP

In the first part of this three-part series, you learned the guiding concepts and design for building a PHP web application to count back links from unique domains using the Yahoo Site Explorer API. In this part, we will illustrate, in detail, how to do the programming for the PHP Ajax web form and the validation script.

  1. Building a Form to Count Back Links Using Yahoo Inbound Links API
  2. AJAX and variables for web form
  3. PHP Script Preliminary Form Processing
  4. Validating the Root Domain Name URL using PHP
By: Codex-M
Rating: starstarstarstarstar / 7
January 25, 2010

print this article



This is the start of the PHP script (yahooapiajax.php) which first receives inputs from AJAX via $_POST. Again at the top of the PHP script, place the following:



This is to let PHP capture the correct captcha answer generated by the captcha script: captcha.php

The first thing the PHP script should do is receive the variables passed as parameters on the AJAX query discussed earlier:

$domainurl =trim($_POST['domainurl']);

$options1 =trim($_POST['options1']);

$options2 =trim($_POST['options2']);

$usercaptchaanswer =trim($_POST['captcha']);

$correctcaptcha = $_SESSION['answer'];

The trim function is used to remove any unnecessary spaces in the user input. $_POST values from the form input are assigned to their respective PHP variables.

The next step is to validate the captcha, and to display an error (as well as terminate the script executing) if the captcha entered does not match the correct answer or f it is entered empty:

if (($correctcaptcha != $usercaptchaanswer) || (empty($usercaptchaanswer))) {

echo 'ERROR: You have not entered captcha code or it is entered incorrectly.';

die ();


>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: