hippo_ajax_form_exec.php

来自「create Ajax Select form」· PHP 代码 · 共 92 行

PHP
92
字号
<?php
  header("Cache-Control", "no-cache");
  header("Pragma", "no-cache");
  header("Expires", "-1");
  
  require('hippo_ajax_form_functions.php');
  
  $divid = $_GET['divid'];
  
  /* Submit Data*/
  if(isset($_POST['aryFormData']))
  {
    $aryFormData = $_POST['aryFormData'];
  
    for($i=0; $i<count($aryFormData); $i++)
    {
      echo $aryFormData[$i].'<br>';
    }
    echo '<br>all data had been inserted to database (simulated...)';
  }
  else /*Else: if(isset($_POST['aryFormData']))*/
  {
    $trimDivID = eregi_replace('divID', '', $divid);
    switch($trimDivID)
    {
      case 'email':
        $tmp = '1';
        if(isValidateEmail($_GET[$trimDivID]))
        {
          echo 'statusOKText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        else
        {
          echo 'statusErrorText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        break;
        
      case 'chineseid':
        $tmp = '2';
        if(isValidChineseID($_GET[$trimDivID]))
        {
          echo 'statusOKText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        else
        {
          echo 'statusErrorText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        break;
        
      case 'cellphone':
        $tmp = '3';
        if(isValidateCellPhone($_GET[$trimDivID]))
        {
          echo 'statusOKText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        else
        {
          echo 'statusErrorText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        break;
      
      case 'tel':
        $tmp = '4';
        if(isValidatePhone($_GET[$trimDivID]))
        {
          echo 'statusOKText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        else
        {
          echo 'statusErrorText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        break;
      case 'select1':
        $tmp = '5';
        if($_GET[$trimDivID]!='Default')
        {
          echo 'statusOKText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        else
        {
          echo 'statusErrorText(\''.$divid.'\','. '\''. $tmp  .'\'' .')';
        }
        break;
      default:
        /*echo 'error occurred';*/
        break;
    }
  } /*End: if(isset($_POST['aryFormData']))*/
  
  
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?