Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/06/2015, 14:51
Avatar de pcarvajal
pcarvajal
 
Fecha de Ingreso: enero-2002
Mensajes: 701
Antigüedad: 22 años, 3 meses
Puntos: 8
como hacer un link con node?

Me explico...

Tengo 3 archivos js:

login.js
Código PHP:
var http = require('http');
var 
html = require('./html');

http.createServer(function (reqres) {
    if(
req.method == 'POST'){
    
        var 
body "";
        var 
input1 "";
        var 
input2 "";
        
        
req.on('data', function (chunk) { body += chunk; });
      
        
req.on('end', function () { ...    });
    }else{
        
res.writeHead(200, {'Content-Type''text/html'});
        
res.end(html.htmlLogin());        
    }
}).
listen(3000'127.0.0.1'); 
registro.js
Código PHP:
var http = require('http');
var 
html = require('./html');

http.createServer(function (reqres) {
    if(
req.method == 'POST'){
    
        var 
body "";
        var 
input1 "";
        var 
input2 "";
        
        
req.on('data', function (chunk) { body += chunk; });
      
        
req.on('end', function () { ...    });
    }else{
        
res.writeHead(200, {'Content-Type''text/html'});
        
res.end(html.htmlRegistro());        
    }
}).
listen(3000'127.0.0.1'); 
html.js --> aqui van todas las plantillas html
Código PHP:
function htmlLogin(usrpwd){
    var 
html ='<html>''\n';
        
html +='<head>''\n';
        
html +='<title>Login</title>''\n';
        
html +='</head>''\n';
        
html +='<body>''\n';
        
html +='<form method="post" name="frmLogin" id="frmLogin">''\n';
        
html +='<h1>Login</h1>''\n';
        
html +='<h2>usuario</h2><input name="input1" id="input1"  type="text"><br>''\n';
        
html +='<h2>password</h2><input name="input2" id="input2"  type="password"><br>''\n';
        
html +='<br><input type="submit" value="Conectar">''\n';
        
html +='<br><br>[B][COLOR="Red"]<a href="#">{recuperar contrase&ntilde;a}</a>[/COLOR][/B]''\n';
        
html +='</form>''\n';
        
html +='</body>''\n';
        
html +='</html>';
    return 
html;
}

function 
htmlRegistro(){
    var 
html ='<html>''\n';
        
html +='<head>''\n';
        
html +='<title>Registro</title>''\n';
        
html +='</head>''\n';
        
html +='<body>''\n';
        
html +='<form method="post" name="frmRegistro" id="frmRegistro">''\n';
        
html +='<h1>Registro</h1>''\n';
        
html +='<h2>usuario</h2><input name="input1" id="input1" type="text"><br>';
        
html +='<h2>password</h2><input name="input2" id="input2" type="password"><br>''\n';
        
html +='<h2>email</h2><input name="input3" id="input3" type="text"><br>''\n';
        
html +='<br><input type="submit" value="Continuar">''\n';
        
html +='</form>''\n';
        
html +='</body>''\n';
        
html +='</html>''\n';
    return 
html;

ojo! antes que me reten, les digo altiro que soy nuevo en esto!!!
Lo que quiero es que al hacer click en el link de recuperar contrasena de login.js, me cargue el template del registro.
se puede hacer eso??????????
__________________
18 laaaaargos años en FDW... y soy de los pocos que ví correr sangre! :X