BigInventoR
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Помогите пожалуйста понять, почему значения которые возвращаются в поля вместо ОК или ERROR под PHP5.3 становятся null? Версия xajax 0.6 beta1, на 0.5 не работает. index.php Код: <?php require_once ("xajax_core/xajax.inc.php"); require_once ("control.php"); require_once ("result.php"); $xajax = new xajax(); $xajax->configure("debug", true); // регистрация функций $xajax->register(XAJAX_FUNCTION,"Control"); $xajax->register(XAJAX_FUNCTION,"Result"); $xajax->processRequest(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title> Пример 1 (глава 8)к книге </title> <?php $xajax->printJavascript(''); ?> </head> <body> <!-- шапка --> <div id=header1><b>Примеры к книге (глава 8 пример 1)<br> Вывод результатов с использованием Smarty</b></div> <br> <!-- Форма --> <div id='div1'> <form id='Form1' action='javascript:void(null);' onsubmit=' xajax.$("Button_Form1").disabled=true; xajax.$("Button_Form1").value="Подождите..."; xajax_Result(xajax.getFormValues("Form1"));'> <table> <!-- login --> <tr> <td>Логин (5-15 буквы,цифры)</td> <td><input type='text' name='login' id='login' value='' onchange='xajax_Control(xajax.getFormValues("Form1"));'></td> <td><div id='error_login'><font color='red'>no</font></div></td> </tr> <!-- password --> <tr> <td>Пароль (5-15 буквы,цифры)</td> <td><input type='password' name='password' id='password' onchange='xajax_Control(xajax.getFormValues("Form1"));'></td> <td><div id='error_password'><font color='red'>no</font></div></td> </tr> <!-- подтверждение password --> <tr> <td>Повторите пароль</td> <td><input type='password' name='password1' id='password1' value='' onchange='xajax_Control(xajax.getFormValues("Form1"));'></td> <td><div id='error_password1'><font color='red'>no</font></div></td> </tr> <!-- email --> <tr> <td>Ваш e-mail</td> <td><input type='input' name='email' id='email' value='' onchange='xajax_Control(xajax.getFormValues("Form1"));'></td> <td><div id='error_email'><font color='red'>no</font></div></td> </tr> <tr> <td></td> <td><input type='submit' id='Button_Form1' disabled=true value='Зарегистрироваться ->' ></td> <td></td> </tr> </table> </div> <div id='result'> </div> </body> </html> | control.php Код: <?php // Проверка правильности заполнения полей // при регистрации пользователя function Control($Id) { $objResponse = new xajaxResponse(); // $objResponse->setCharEncoding('windows-1251'); $count=0; // login if(!preg_match("/^([a-z,A-Z,а-я,А-Я,0-9]{5,15})$/",$Id[login])) $objResponse->assign("error_login","innerHTML","<font color='red'>ERROR</font>"); else { $objResponse->assign("error_login","innerHTML","<font color='blue'>ОК</font>"); $count++; } // password if(!preg_match("/^([a-z,A-Z,а-я,А-Я,0-9]{5,15})$/",$Id[password])) $objResponse->assign("error_password","innerHTML","<font color='red'>ERROR</font>"); else { $objResponse->assign("error_password","innerHTML","<font color='blue'>ОК</font>"); $count++; } // password1 if($Id[password1]==$Id[password] && strlen($Id[password1])>0) { $objResponse->assign("error_password1","innerHTML","<font color='blue'>ОК</font>"); $count++; } elseif(strlen(trim($Id[password1]))==0) { $objResponse->assign("error_password1","innerHTML","<font color='red'>ERROR</font>"); } else { $objResponse->assign("error_password1","innerHTML","<font color='red'><>password!</font>"); } // email if(preg_match("/^([a-z,0-9,-_\.]{2,20})([\@]{1})([a-z,0-9,-_]{2,20})([\.]{1})([a-z,]{1,3})$/",$Id[email])) { $objResponse->assign("error_email","innerHTML","<font color='blue'>ОК</font>"); $count++; } else $objResponse->assign("error_email","innerHTML","<font color='red'>ERROR</font>"); if($count==4) $objResponse->assign("Button_Form1","disabled",false); else $objResponse->assign("Button_Form1","disabled",true); return $objResponse; } ?> | result.php Код: <?php function Result($Id) { $objResponse = new xajaxResponse(); $objResponse->assign("Button_Form1","disabled",true); $objResponse->assign("Button_Form1","value","Зарегистрироваться ->"); $objResponse->assign("login","value",""); $objResponse->assign("password","value",""); $objResponse->assign("password1","value",""); $objResponse->assign("email","value",""); $text1="Успешная регистрация<br>"; $text1.="Ваши данные:<br>"; $text1.="Логин - ".$Id[login]."<br>"; $text1.="Пароль - ".$Id[password]."<br>"; $text1.="E-mail - ".$Id[email]."<br>"; $objResponse->assign("result","innerHTML",$text1); return $objResponse; } ?> |
|