Question

I'm trying to make an app with an login form (index.html) and a mini control panel (panel.html), but when i try to login the app only show the Notificaction and dont redirect to the panel.html page.

This is the code of my index.html

    <script type="text/javascript">
    function loginTrue() {
                  Ti.UI.currentWindow.setURL("app://panel.html");
    }
    function showNotify(title, message) {
                  var notification = Ti.Notification.createNotification({
                    'title': title || 'Sin Titulo',
                    'message': message || 'Sin mensaje',
                    'timeout': 10
                  });
                  notification.show();
                }
        </script>
        <script type="text/javascript">

        </script>
        <script type="text/python">
            import MySQLdb
            import os
            db = MySQLdb.connect(host="localhost",user="root", passwd="toor", db="db")
            cursor = db.cursor()
            def login():
                username= document.getElementById('usuario').value;
                passw= document.getElementById('contrasena').value;
                cursor.execute("SELECT * FROM usuarios WHERE userlUsuario='"+username+"' and userContrasena='"+passw+"'" )
                res = cursor.fetchone()
                if(res==None):
                    showNotify("Error!", "Datos Invalidos, intente de nuevo.");
                else:
                    showNotify("Acceso!", "Login Correcto!");
                    loginTrue();

        </script>
<!DOCTYPE html>
<head>
    <link rel="stylesheet" href="css/style.css" media="all" />
</head>
<body class="login">
    <div class="login">
        <section id="login">
            <h1><strong>Login</strong></h1>
            <form method="link">
                <input id="usuario" type="text" placeholder="Usuario" />
                <input id="contrasena" type="password" placeholder="Contraseña" />
                <button class="blue" onclick="login()">Entrar</button>
            </form>
        </section>
    </div>
</body>
</html>
Was it helpful?

Solution

I found it, the problem was with the Login form that redirects the page to it self when someone click on the submit button, i resolve it adding "javascript:void(0);" as action of the form.

<form action="javascript:void(0);">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top