简体   繁体   English

Javascript,将用户详细信息保存到数据库

[英]Javascript, saving user details to a database

I'm teaching myself some web development on the side, and just for fun I'm trying to build a small e-commerce website for my gf (She might actually use it for a business idea if I don't get side tracked and not finish in time)我正在自学一些 Web 开发,只是为了好玩,我正在尝试为我的女朋友建立一个小型电子商务网站(如果我没有被忽视和没有及时完成)

So I've managed to build a basic front end with html, css and javascript... The 1st hurdle I've run into is saving basic user details to a database, could someone please guide me in the right direction on what would be the quickest and easiest way to accomplish this.所以我设法用 html、css 和 javascript 构建了一个基本的前端......我遇到的第一个障碍是将基本的用户详细信息保存到数据库中,有人可以指导我正确的方向吗?实现这一目标的最快捷、最简单的方法。

The only other programming language I have a decent grasp of (certification level) is Java我唯一熟悉的其他编程语言(认证级别)是 Java

Thanks in advance提前致谢

Nowadays, the best way to store user details is probably to NOT store them at all lol.如今,存储用户详细信息的最佳方式可能是根本不存储它们,哈哈。 If you can use any third party authentication like Facebook or google, i really think you should give it a try.如果您可以使用 Facebook 或 google 等任何第三方身份验证,我真的认为您应该尝试一下。 If you really feel like doing your own login/sign up.如果您真的想自己登录/注册。 It's gonna be in the back-end.它会在后端。 Using PHP is easy if you don't have any experience in that kind of stuff.如果您对这类东西没有任何经验,那么使用 PHP 很容易。

This is an example of something not too bad 这是一个不太糟糕的例子

hope it answers your question.希望它能回答你的问题。 If not, let me know and i can give you some more details !如果没有,请告诉我,我可以为您提供更多详细信息!

This question can not be answered in a few sentences.这个问题不能用几句话来回答。 But have a look:但是看看:

Javascript is executed on the client side while PHP for example is executed on the server. Javascript 在客户端执行,而 PHP 例如在服务器上执行。 You need to send a so called HTTP Request to your PHP server using javascript.您需要使用 javascript 向 PHP 服务器发送所谓的HTTP Request This can be done with jQuery via ajax() function or using native JS like:这可以通过ajax()函数使用jQuery或使用本机 JS 来完成,例如:

var xmlhttp = new XMLHttpRequest();
var url = "myTutorials.txt";

xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    var myArr = JSON.parse(xmlhttp.responseText);
    console.log(myArr);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();

http://www.w3schools.com/json/json_http.asp http://www.w3schools.com/json/json_http.asp

but i strongly recommend u to use jQuery:但我强烈建议你使用 jQuery:

http://api.jquery.com/jquery.ajax/ http://api.jquery.com/jquery.ajax/

What happens during such a http request?在这样的 http 请求期间会发生什么? The Client (your PC) sends data via an URL to the webserver and u receive it in the response.客户端(您的 PC)通过 URL 将数据发送到网络服务器,您在响应中接收它。 (have a look at the response in your development tool) (看看你的开发工具中的响应)

greetings你好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM