leoretorico Posted March 24, 2014 Report Share Posted March 24, 2014 Boa tarde sou novo em Html e javascript Tenho o código abaixo , um login sem base de dados..ele usa arquivos de texto. Preciso pegar o nome do usuário digitado quando o login for correto e passar para outra página html ..para verificar se este usuário está logado . Seria usando o method get? como posso implementar? <script> function click() { if (event.button==2||event.button==3) { oncontextmenu='return false'; } } document.onmousedown=click document.oncontextmenu = new Function("return false;") </script> <script type="text/javascript"> <!-- function authPass(u,p) { if (u && p) self.location = "Auth.html?" + u + p; return false; } // --> </script> <form id="form1" action="javascript://" onsubmit="return authPass(this.user.value,this.pass.value)"><table> <tr> <td>Usuário: </td><td><input type="text" name="user" /></td> </tr> <tr> <td>Senha: </td><td><input type="password" name="pass" /></td> </tr> <tr> <td colspan="4" align="left"><input type="submit" value="Entrar .." /><input name="Lembrar" type="button" onclick="window.open('hhttp://www.portugal-a-programar.pt/')" value="Recuperar a senha" /></td> </tr> </table> </form> Eu encontrei este código na web ... funciona perfeitamente ... mas não sei implementar no código acima! <form action="HTML.html" method="GET"> <textarea rows="7" cols="30" name="text"></textarea> <button type="submit">send</button> </form> HTML.html: <script type="text/javascript"> window.onload = function () { document.write(window.location.search.split('=')[1]); }; Link to comment Share on other sites More sharing options...
I-NOZex Posted March 24, 2014 Report Share Posted March 24, 2014 afik, js nao permite ler ficheiros (existe uma bibliteca qqr que junto com html5 consegue alguma coisa do genero...) B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net Link to comment Share on other sites More sharing options...
leoretorico Posted March 24, 2014 Author Report Share Posted March 24, 2014 Eu só preciso pegar a string do USERNAME e passar para uma outra página quando você apertar o botão Username = Leo página1.html >>>>>>>>> pagina2.html / label = leo Link to comment Share on other sites More sharing options...
Devexz Posted March 24, 2014 Report Share Posted March 24, 2014 (edited) decide-te o que queres, no primeiro post dizes uma coisa e agora dizes outra, é que em termos de programação isso faz toda a diferença. Edited March 24, 2014 by Devexz Contador de calorias: caloriaspordia.com Link to comment Share on other sites More sharing options...
Devexz Posted March 24, 2014 Report Share Posted March 24, 2014 (edited) decide-te o que queres, no primeiro post dizes uma coisa e agora dizes uma coisa diferente... Tenho o código abaixo , um login sem base de dados..ele usa arquivos de texto. Preciso pegar o nome do usuário digitado quando o login for correto e passar para outra página html ..para verificar se este usuário está logado . Eu só preciso pegar a string do USERNAME e passar para uma outra página quando você apertar o botão Username = Leo página1.html >>>>>>>>> pagina2.html / label = leo Edited March 24, 2014 by Devexz Contador de calorias: caloriaspordia.com Link to comment Share on other sites More sharing options...
KTachyon Posted March 24, 2014 Report Share Posted March 24, 2014 Podes utilizar um cookie. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
leoretorico Posted March 25, 2014 Author Report Share Posted March 25, 2014 Eu não falei duas coisas diferentes ... Eu disse que o login usa um arquivo de texto ... mas minha necessidade é pegar o nome digitado do username e jogar para uma label ,ou páragrafo (Para algum lugar) na página que vai abrir! Link to comment Share on other sites More sharing options...
KTachyon Posted March 25, 2014 Report Share Posted March 25, 2014 Mais uma vez: usa um cookie. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
leoretorico Posted March 25, 2014 Author Report Share Posted March 25, 2014 Pode me dar um exemplo? Eu agradeceria muito Link to comment Share on other sites More sharing options...
KTachyon Posted March 25, 2014 Report Share Posted March 25, 2014 http://www.w3schools.com/js/js_cookies.asp // Escrever para um cookie: document.cookie="username=John Doe"; // Ler do cookie var x = document.cookie; “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now