Me explico...
Tengo 3 archivos js:
login.js
Código PHP:
var http = require('http');
var html = require('./html');
http.createServer(function (req, res) {
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 (req, res) {
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(usr, pwd){
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ñ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??????????