简体   繁体   中英

Where Can I Find Tutorials for Creating a onesided registration and login system?

What I mean is, I would like a tutorial of creating a login system in php, were I assign the username and password, and give it to the users I want to be able to access https://fileshare.parlocameoncorporation.com . First, I will explain how my system works. Chart: index.html(access granted screen) -> select.html(request file) -> downloader.php(displays progress bar and request file download) from -> download.php. Thank you for your time. Ps there is a code bug, and I'm sorry for a possibly insulting message that involves hacking if you request a file that's not found. As a example file, please request example.txt.

You'd need to read up on sending POST requests for a login (either with jQuery ajax requests, or by using a standard html form), and also on Sessions.

With a session, you can store userdata safely on the server. Works like this: The browser gets a Cookie, normally PHPSESSID, which is used to identify the user. That way the server can connect this PHPSESSID with the locally stored session information.

For checking username and password, you'd need to use MySQLi PreparedStatements (to prevent SQL Injections). You'd need to check whether an entry with the given username and password exists on a login table in the database. If yes, write the username to the session, if not, give an error.

Now, in your downloader.php etc, you can check whether this Session value exists, if not, redirect them to the login page.

Write to Session:

session_start();
$_SESSION["uname"] = $_POST["username"];

That way you write the username you got via the POST request into the session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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