【问题标题】:Suggest User name based on full name and date of birth根据全名和出生日期建议用户名
【发布时间】:2018-07-20 20:54:33
【问题描述】:

HTML -

<form action="/addUser" method="post">
                <div class="Fields hideme">
                    <label class="form__fields">Full Name :<span class="star"> * </span></label>
                    <input class="input" type="text" name="full_name" placeholder="Enter your name" required><br/>
                </div>
                <div class="Fields hideme">
                    <label class="form__fields">Address line 1:<span class="star"> * </span></label>
                    <input class="input" type="text" name="address_line_1" placeholder="Address line 1" required><br/>
                </div>    
                <div class="Fields hideme">
                    <label class="form__fields">DOB :<span class="star"> * </span></label>
                    <input class="input" type="date" name="DOB" placeholder="DOB" required><br/>
                </div>    
                </div>
                <div class="Fields hideme">
                    <label class="form__fields">Email :<span class="star"> * </span></label>
                    <input class="input" type="email" name="email" placeholder="Enter your E-mail" required><br/>
                </div>
                <div class="Fields hideme">
                    <input class="Submit_button" type="submit" value="Submit">
                </div>
            </form>

我正在使用 node.js 保存这个用户

JS -

var nameSchema = new mongoose.Schema({
    full_Name: String,
    .
    .
    email: String
});
var User = mongoose.model("User", nameSchema);
const publicPath = path.join(__dirname,'/');

app.use(express.static(publicPath));

app.post("/addUser", (req, res) => {
    var myData = new User(req.body);
    myData.save()
        .then(item => {
            res.send("User saved to database");
        })
        .catch(err => {
            res.status(400).send("Unable to save to database");
        });
});

我有一个 html 表单,我在其中要求用户输入姓名、出生日期、地址、电子邮件等信息,并且我必须根据这些输入向用户建议用户名。 请告诉我如何根据用户的输入(全名、出生日期、地址)发回建议的用户名。

【问题讨论】:

    标签: html node.js


    【解决方案1】:

    我想在 cmets 上写文章,但我没有足够的声誉。 所以我会写它作为答案。 我个人建议您使用 heroku 或 digitalocean,因为它们非常适合 nodejs。 如果您使用 MongoDB,mlab 最适合您的数据库。 你可以谷歌它或在 youtube 上搜索有大量的信息。 希望你能找到答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-16
      • 2019-01-09
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      • 1970-01-01
      • 2014-01-04
      相关资源
      最近更新 更多