Google Groups Home
Help | Sign in
A working Login sample
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
ebarchiesi  
View profile
 More options May 2, 5:20 pm
From: ebarchiesi <ebarchi...@gmail.com>
Date: Fri, 2 May 2008 14:20:02 -0700 (PDT)
Local: Fri, May 2 2008 5:20 pm
Subject: A working Login sample
Hi!
Here i developed a login form using phpext. The problem exists when i
submit the form that i am including a javascript with Extjs code to
check if the login is ok or not.
Someone could help me to replace this code with native phpext code.
I will pubish all my avances using phpext here, since i am planing to
do a complete apllication using that framework.

Here is the code

<?php
$SITE = array();
$SITE["localhost"] = "http://".$_SERVER['HTTP_HOST'];
$SITE["root"] = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']);
$SITE["dir"] = str_replace("\\","/",dirname(__FILE__));
$SITE["base"] = str_replace($SITE["root"],$SITE["localhost"],
$SITE["dir"]);
// modulos
set_include_path(get_include_path().";".realpath("./library"));

include_once 'PhpExt/Javascript.php';// setea el encabezado
//PhpExt_Javascript::sendContentType();

include_once 'PhpExt/Ext.php';
include_once 'PhpExt/Window.php';
include_once 'PhpExt/Handler.php';
include_once 'PhpExt/AutoLoadConfigObject.php';
include_once 'PhpExt/Layout/FitLayout.php';
include_once 'PhpExt/Panel.php';
include_once 'PhpExt/Form/FormPanel.php';
include_once 'PhpExt/Form/TextField.php';
include_once 'PhpExt/Form/PasswordField.php';
include_once 'PhpExt/Button.php';
include_once 'PhpExt/Layout/AnchorLayoutData.php';
include_once 'PhpExt/QuickTips.php';
include_once 'PhpExt/Layout/ColumnLayout.php';
include_once 'PhpExt/Layout/FormLayout.php';
include_once 'PhpExt/Layout/FitLayout.php';
include_once 'PhpExt/Layout/ColumnLayoutData.php';

// login
$Form = new PhpExt_Form_FormPanel();
$Form->labelWidth =  80;
$Form->url =                         'index.php?section=auth&sub=login';
$Form->frame =                       true;
$Form->width =                       230;
$Form->defaultType=          'textfield';
$Form->monitorValid =        true;
// Items
$user = new PhpExt_Form_TextField();
$user->createTextField("loginUsername");
$user->setAllowBlank(false);
$user->setFieldLabel("Usuario");

$password = new PhpExt_Form_PassworField();
$password->createTextField("loginPassword");
$password->setAllowBlank(false);
$password->setFieldLabel("Contraseña");

// boton

$click = PhpExt_Javascript::stm("

                    Form.getForm().submit({
                        method:'POST',
                        waitTitle:'Conectando',
                        waitMsg:'Enviando datos...',
                        success:function(){
                        Ext.Msg.alert('Estado', 'Ingreso correcto!',
function(btn, text){
                                                   if (btn == 'ok'){
                                                                                var redirect = 'index.php';
                                                                                window.location = redirect;
                                                                }
                                                        });
                        },
                        failure:function(form, action){
                            if(action.failureType == 'server'){
                                obj =
Ext.util.JSON.decode(action.response.responseText);
                                Ext.Msg.alert('Acceso denegado!',
obj.errors.reason);
                            }else{
                                Ext.Msg.alert('Cuidado!', 'No se puede
resolver la petición del servidor : ' + action.response.responseText +
'abcd');
                            }
                            Form.getForm().reset();
                        }
                    });
                ");
$func = new PhpExt_Handler($click);

$button = new PhpExt_Button();
$button->createTextButton("Submit");
$button->text ="Ingresar";
$button->setHandler($func);

// agrega al formulario
$Form->addItem($user, new PhpExt_Layout_AnchorLayoutData("100%"));
$Form->addItem($password, new PhpExt_Layout_AnchorLayoutData("100%"));
$Form->addButton(PhpExt_Button::createTextButton("Cancelar"));
$Form->addButton($button);

$window = new PhpExt_Window();
$window->title = 'Ingreso al sistema';
$window->setWidth(300);
$window->setHeight(150);
$window->closable = false;
$window->resizable = false;
$window->setLayout(new PhpExt_Layout_FitLayout());
$window->setPlain(true);
$window->setBodyStyle("padding:10px");
$window->addItem($Form);
$customHeaders = '
            <link rel="stylesheet" type="text/css" href="resources/ext-2.0.2/
resources/css/ext-all.css" />
                <!-- LIBS -->
                <script type="text/javascript" src="resources/ext-2.0.2/adapter/ext/
ext-base.js"></script>
                <!-- ENDLIBS -->
            <script type="text/javascript" src="resources/codepress/
codepress.js"></script>
                <script type="text/javascript" src="resources/ext-2.0.2/ext-
all.js"></script>
';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Login  - Enrique Barchiesi</title>
    <base href="<?php echo $SITE["base"]; ?>/" />
    <link rel="stylesheet" type="text/css" href="site.css" />
<?php if (isset($customHeaders)) echo $customHeaders;?>
</head>
<body>
<script>
<?php
echo PhpExt_Ext::onReady(
        $Form->getJavascript(false, "Form"),
        $window->getJavascript(false, "window"),
        $window->show()
);
?>
</script>

</body>
</html>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google