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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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:


<?php


session_start();


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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: