Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中创建登录系统?_Php_Login_Login Script - Fatal编程技术网

如何在php中创建登录系统?

如何在php中创建登录系统?,php,login,login-script,Php,Login,Login Script,很抱歉,我是一个新手,这个网站主要是为专业程序员。但我来自一家公司,我需要认真的帮助。我查看了如何创建登录脚本。我运行了登录,单击提交后,显示了一个包含我的代码的页面,但代码没有运行。我需要你的建议,创建一个登录脚本,以及如何使其工作。解释而不是链接会有所帮助 <!DOCTYPE html> <html> <head> <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300

很抱歉,我是一个新手,这个网站主要是为专业程序员。但我来自一家公司,我需要认真的帮助。我查看了如何创建登录脚本。我运行了登录,单击提交后,显示了一个包含我的代码的页面,但代码没有运行。我需要你的建议,创建一个登录脚本,以及如何使其工作。解释而不是链接会有所帮助

<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Quicksand:400,700' rel='stylesheet' type='text/css'>
<link href="logincss.css" rel='stylesheet' type='text/css'>
</head>

<body>
<div class="login">
<h1 class="logintitle">Login to Phantoms </h1>

<form method="post" action="checklogin.php" name="login">
  <center><input type="username" name="username" placeholder="Username" id="username" required="required" minlength="4" maxlength="30"></center>

  <center><input type="password" name="password" placeholder="Password" id="password" required="required" minlength="3" maxlength="20"></center>

  <center><input type="submit" name="login" id="loginsubmit" value="Login to Phantoms">
</form>

<div class="options">
<a href="#" class="register">Register</a>
<a href="#" class="passwordrecovery">Forgot Username or Password</a>



</form> 
</div>
**链接到checklogin脚本:


**

您编写的脚本非常基本,但可以正常工作。 不过在你的剧本里看起来很奇怪

session_register("myusername");
session_register("mypassword"); 
您可以使用这样的函数注册会话,将会话ID存储在新列session_ID下的user表中的数据库中,添加另一列last_active,browser_information user agent,ip以存储用户的ip

在每个页面上,都需要调用bool check_session$session_id等加载函数,以检查所有session_id、浏览器信息和ip是否仍然匹配

这就是如何编写新函数的简单方法,StackOverflow的工作不是为您编写代码,我希望这会有所帮助

编辑:正如我在评论中所建议的,这个答案应该扩展


Fred-ii-建议使用或进行密码存储,使用或PHP5.5的函数。对于PHP<5.5,请使用。

欢迎使用堆栈溢出!这个问题缺乏信息。你能分享你的尝试吗?你遇到了什么问题?你的网页是在web服务器上运行的吗?该服务器上是否运行PHP?但我来自一家公司,我需要认真的帮助。-啊,一家公司。然后雇佣一个开发者。@JayBlanchard确保你有很多;我倾向于几秒钟和三分之一的时间-我能做马古!当我煮小龙虾时,我煮了很多小龙虾@Fred ii-,真的吗?Gawd,这甚至不能回答眼前的问题。这又是一个标题:如何用php创建登录系统?这是他的代码,不是我的。他问我怎么做,所以我给了他一个主意。这就是OP的全部。他们想让我们来填补剩下的部分。@DeDee对这个糟糕的问题提供糟糕的答案肯定不是你想要的方式,是吗?“我很惊讶你还没拿到DV,”弗雷德二世-完蛋了,我花了一分钟的时间记下了那个价格。