我希望实现一个php文件,该文件可以在此之后立即执行用户注册和登录操作。
我认为程式码的结构应如下:
注册与login.php
<?php
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
//Check the fields.If they are correct
//Check if the username exists and password is correct
$_SESSION['login_user']=$username;
//Go to the profile.php.
//But if the username does not exists, insert the username and password in table}
else {mysql_close($connection);}上面的代码能正常工作吗?这是我问题的一个很好的答案吗?
发布于 2015-07-31 07:38:52
这也是个好办法..。
首先检查用户名/电子邮件用户是否已经存在
如果存在,则匹配用户名和密码,并为该用户创建会话。
如果没有,则创建用户,然后为该用户创建一个会话(这意味着用户也已登录)。
https://stackoverflow.com/questions/31740611
复制相似问题