|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表单的重要性</title>
</head>
<body>
<form name="signupform" action="http://localhost:8080/form" method="post">
<input type="text" name="username" placeholder="Email" /> <br/>
<input type="password" name="password" placeholder="Password" /> <br/>
<input type="password" name="confirm-_assword" placeholder="Re-Enter password"/> <br/>
<input type="checkbox" name="list_mail" value="1" />
<span>Please send me emails about special offers, exclusives and promotions monthly. </span> <br/>
<input type="checkbox" name="agreement" checked="checked" value="1" />
<span>I agree to Sanydress.com <a target="_blank" href="terms-of-use-a92.html">Terms and Conditions</a></span> <br/>
<button type="submit" name="submit">
<em>
<span>REGISTER</span>
</em>
</button>
</form>
</body>
</html>
--form.html
对于开发和维护外贸网站的我而言,我所提供给你们的这些代码还是很有实用价值的
不要轻视这些,这段代码可以说,少了css、js和php的互动,因为我们还没学到css,所以这只是从这学起,从而能够把基础打牢。
别看这段代码简单,其实里面用了node.js的功能
希望你们安装下node.js。这个东西能够让你们看到你们提交的表单内容,
下面,我给你们js代码,希望你们能用nodejs.exe执行下这段代码
var http = require('http');
var querystring = require('querystring');
http.createServer(function(req, res) {
switch (req.url) {
case '/form':
if (req.method == 'POST') {
console.log("[200] " + req.method + " to " + req.url);
var fullBody = '';
req.on('data', function(chunk) {
fullBody += chunk.toString();
});
req.on('end', function() {
res.writeHead(200, "OK", {
'Content-Type': 'text/html'
});
res.write('<html><head><title>Post data</title></head><body>');
res.write('<style>th, td {text-align:left; padding:5px; color:black}\n');
res.write('th {background-color:grey; color:white; min-width:10em}\n');
res.write('td {background-color:lightgrey}\n');
res.write('caption {font-weight:bold}</style>');
res.write('<table border="1"><caption>Form Data</caption>');
res.write('<tr><th>Name</th><th>Value</th>');
var dBody = querystring.parse(fullBody);
for (var prop in dBody) {
res.write("<tr><td>" + prop + "</td><td>" + dBody[prop] + "</td></tr>");
}
res.write('</table></body></html>');
res.end();
});
} else {
console.log("[405] " + req.method + " to " + req.url);
res.writeHead(405, "Method not supported", {
'Content-Type': 'text/html'
});
res.end('<html><head><title>405 - Method not supported</title></head><body>' +
'<h1>Method not supported.</h1></body></html>');
}
break;
default:
res.writeHead(404, "Not found", {
'Content-Type': 'text/html'
});
res.end('<html><head><title>404 - Not found</title></head><body>' +
'<h1>Not found.</h1></body></html>');
console.log("[404] " + req.method + " to " + req.url);
};
}).listen(8080);
这段代码能是服务器上脚本,能显示你表单提交了哪些内容
|
|