0

What shall I modify on this code to make it clear to the browsers that "you can save this fields". (For that users who don't want to enter them any time)

(browser info and resolution are hidden fields for statistics)

<form id='log_in' action='/_fn/log_in.php' method=post>
                <ul id='m1_bal'>
                    <!--<li><a HREF='/print' TITLE='belépés' tabindex=3><img WIDTH=32 HEIGHT=32 ALT='' SRC='/images/menu1/nyil.png'></a></li>-->
                    <li><input type=submit value='belépés' tabindex=3></li>
                    <li><!--[if IE]>jelszó:<![endif]--><input name='password' tabindex=2 type=password placeholder='jelszó'></li>       
                    <li><!--[if IE]>email:<![endif]--><input name='email' tabindex=1 type=text placeholder='email'></li>                        
                    <input name='felbontas' type=hidden>
                    <input name='bongeszo' type=hidden>
                    <input name='href' type=hidden>
                </ul>
            </form>

The javascript code:

$('#log_in').submit(function(e){
    //browser info
    var b = "?";
    if( $.browser.msie)b = "IE";
    if( $.browser.webkit)b = "Webkit";//Chrome/Safari
    if( $.browser.opera)b = "Opera";
    if( $.browser.mozilla)b = "Mozilla";
    var bongeszo = b+" "+$.browser.version;
    //resolution
    var felbontas = $(document).width()+"x"+$(document).height();


            /* METHOD 2
    $(this).find('input[name=bongeszo]').val(bongeszo);
    $(this).find('input[name=felbontas]').val(felbontas);
    $(this).find('input[name=href]').val(window.location.href);
    */

    e.preventDefault();
    $.post($(this).attr('action'),{
        email: $(this).find('input[name=email]').val(),
        password: $(this).find('input[name=password]').val(),
        felbontás: felbontas,
        böngésző: bongeszo
        },function(answer){
            if(answer=="1")window.location.reload();else
                alert(answer);
    });

});

If you say: dont use ajax, I tell, that I have tired it without it too. See: METHOD 2

1 Answers1

0

The answer is very interesting:

I used this form http://www.debugtheweb.com/test/passwordautocomplete.asp to make a very simple log in that surely works. I compared it step-by-step with my code and tested it, and finally realized, that the order of the elements was wrong. (I have inverted it because the right floating)

        <form id='log_in_form' action='/_fn/log_in.php' method=post>
            <ul id='m1_jobb'>               
<!--A-->                <li><input type='text' name='email'></li >
<!--B-->                <li><input type='password' name='password'></li >
                <li><input type=submit value='belépés'></li >
            </ul>
        </form>

A and B lines cant be switched!

The AJAXing worked too (so action is ignored) this way:

$('#log_in_form').submit(function(e){
    $.ajaxSetup({async:false});
    $.post($(this).attr('action'),{
        email: $(this).find('input[name=email]').val(),
        password: $(this).find('input[name=password]').val()
        },function(answer){
            if(answer=="1")window.location.href=window.location.href;else{
                e.preventDefault();
                alert(answer);
                }
    });

});