首页 > 开发 > AJAX > 正文

xajax的FORM例子

2024-09-01 08:29:50
字体:
来源:转载
供稿:网友
代码如下:
<?php
// signup.php
// demonstrates a simple multipage form using xajax
// and the xajax.getFormValues() function.
// using xajax version 0.1 beta4
// http://xajax.sourceforge.net
session_start();
include ("xajax.inc.php");
function processForm($aFormValues)
{
        if (array_key_exists("username",$aFormValues))
        {
                return processAccountData($aFormValues);
        }
        else if (array_key_exists("firstName",$aFormValues))
        {
                return processPersonalData($aFormValues);
        }
}
function processAccountData($aFormValues)
{
        $objResponse = new xajaxResponse();
        $bError = false;
        if (trim($aFormValues['username']) == "")
        {
                $objResponse->addAlert("Please enter a username.");
                $bError = true;
        }
        if (trim($aFormValues['newPass1']) == "")
        {
                $objResponse->addAlert("You may not have a blank password.");
                $bError = true;
        }
        if ($aFormValues['newPass1'] != $aFormValues['newPass2'])
        {
                $objResponse->addAlert("Passwords do not match.  Try again.");
                $bError = true;
        }
        if (!$bError)
        {
                $_SESSION = array();
                $_SESSION['newaccount']['username'] = trim($aFormValues['username']);
                $_SESSION['newaccount']['password'] = trim($aFormValues['newPass1']);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表