Part 1: Create your own Login System using PHP and MySql
In this tutorial, I’ll be teaching you how you can create your very own secure PHP login system. A login form is what your website’s visitors can use to log in to your website to access restricted content, such as a profile page. We will leverage MySQL to retrieve account data from the database.
1. Getting Started
There are a few steps we need to take before we create our secure login system. We need to set up our web server environment and ensure we have the required extensions enabled.
1.1. Requirements
- If you haven’t got a local web server set-up, I recommend you download and install XAMPP.
- XAMPP is a cross-platform web server package that includes the essentials for back-end developers. It includes PHP, MySQL, Apache, phpMyAdmin, and more. It’s not necessary to install all the software separately with XAMPP.
1.2. What You Will Learn in this Tutorial
- Form Design — Design a login form with HTML5 and CSS3.
- Prepared SQL Queries — How to properly prepare SQL queries to prevent SQL injection and therefore preventing your database from being exposed.
- Basic Validation — Validating form data that is sent to the server using GET and POST requests (username, password, email, etc.).
- Session Management — Initialize sessions and store retrieved database results. Sessions are saved on the server and are associated with a unique ID that is saved in the browser.
1.3. File Structure & Setup
We can now start our web server and create the files and directories we’re going to use for our login system.
- Open XAMPP Control Panel
- Next to the Apache module click Start
- Next to the MySQL module click Start
- Navigate to XAMPP’s installation directory (C:\xampp)
- Open the htdocs directory
- Create the following directories and files:
File Structure
\– phplogin
|– index.html
|– style.css
|– authenticate.php
|– logout.php
|– home.php
|– profile.php
Each file will consist of the following:
- index.html — The login form created with HTML5 and CSS3. We don’t need to use PHP in this file. Therefore, we can save it as plain HTML.
- style.css — The stylesheet (CSS3) for our secure login system.
- authenticate.php — Authenticate users, connect to the database, validate form data, retrieve database results, and create new sessions.
- logout.php — Destroy the logged-in sessions and redirect the user to the login page.
- home.php — Basic home page for logged-in users.
- profile.php — Retrieve the user’s account details from our MySQL database and populate them with PHP and HTML.
How to upload your website files in cPanel?
Follow these steps on how to upload your website to your HostScripter Web hosting account running cPanel.
Log into the customer (cPanel) portal at https://yourdomain.com/cpanel, Replacing yourdomain.com with your real domain as provided in your welcome email.
You will then be logged into the customer (cPanel) portal for the account you wish to upload the files for.
In the Files section click on the File Manager icon.
Select the Web Root (public_html/www) option and press the Go button.
You will now see the File Manager screen. If there were other files present, delete those files except for the cgi-bin.
Click on the Upload icon.
Press the Browse button to select the file you wish to upload.
Navigate to the file you wish to upload and press the Open button. If uploading multiple files, zip your files.
You will then see a status for the file upload.
When the upload is complete click on the link Back to /home/customer/public_html.
You will now see your uploaded file in your File Manager screen.
Then repeat steps 6 to 10 until you have uploaded all the required files. If you uploaded a zip file, select the zip file and click extract here.
HostScripter migrates all student/budget hosting from cPanel to DirectAdmin access effective January 2020
Previous months, cPanel license price hikes and sparks worldwide criticisms by the hosting industry.
Because of this, we regrettably announced to all our clients including future customers that effectively January 2020, we will be migrating all student and budget hosting packages into DirectAdmin based-server. Thus, we are terminating the use of cPanel control panel for the package as stated.
Ever since we started on 2011, HostScripter has been a reliable choice for cheap and affordable web hosting especially for students and young professionals.
For those who still wanted to continue with the cPanel based-hosting, we encourage you to upgrade your account into premium and business packages. These packages were hosted in a different server with more reliable system resources!
As mentioned above, DirectAdmin application is one of the few alternatives for cPanel. This will not hinder us to use available applications in order to continue providing cheap and affordable hosting packages to our clienteles!
For your inquiries and comments, you can message us at https://www.facebook.com/hostscripter
How to fix HTTP 500 internal server error?
Fix -1: Check the permissions on your web hosting. If the permissions are not set correctly for some important files or scripts, the server tends to show HTTP 500 error on your browser. Check the permissions of .htaccess file. Contact your web hosting provider to know the permission set and fix all your files with right permissions.
Fix – 2: Check the error logs from PHP and Apache on your web server. You must check them as the 500 Internal Server error is too broad and you need to know the exact cause to resolve your website. Error logs provide the context which caused the failure of your website. Generally, the error log file is called error.log. Some cPanels provide the error log file on the dashboard. It may be different on web hosts. Contact your web hosting support if you do not find error log file.
Fix – 3: If you have installed any software or upgraded the existing ones, the old themes, widgets or plugins may fail to comply with the new updates. Check out their support forums if there are any other webmasters who are facing the same issues with the new upgrade. If there are no proper solutions on the forums, you must uninstall or deactivate the plugins and to fix the error. You have to search for an alternative for that plugin or wait for an update.
Fix – 4: 500 Internal Server also shows up when the script timed out or the server timed out. Things like this can only be known if you check the Apache/PHP error logs. You can adjust the server timeout and check if it fixes the issue. You need to increase the timeout from the default time (30 seconds) to something more.
Fix – 5: If the scripts on your website are running on the third-party host, you need to contact their administrator to help you fix the error.
Are you facing the 500 Internal Server Error when you are trying to watch your favorite live videos on Youtube? or Are you seeing the error on Google?
500 Internal Server could be really annoying especially if you are unable to load the website when you need it the most. As the error is a server-side error, you cannot troubleshoot it as it is not the problem from your side. Still, there are few things you can do which might fix and load the website again.
Fix – 1: Try refreshing the browser window. Press “Ctrl+ F5” to force refresh the webpage and serve the fresh content.
Fix – 2: Delete the cookies and cache on your browser. Most of the times 500 Internal Server disappears after clearing the caches on the browser. If you know, this fix helps in solving lots many more Google Chrome Errors including ERR CONNECTION REFUSED & ERR SSL PROTOCOL ERROR.
Fix – 3: If the above two doesn’t work, then you must wait till the webmasters fix the issue. Generally giant websites like Google, Facebook, etc. will resolve it in a couple of minutes.
Fix – 4: If you are browsing to find some information from websites like Wikipedia and see an HTTP 500 Error / 500 Internal Server Error then you can access the old version of the page with the help of Google cache. Copy the URL at which you are seeing the error. Go to Google.com and search the URL. Besides the URL part of the search results, you’ll see a small down sided triangle. Click on it and click on “Cached” to open the cached version of the webpage in the browser. This will not work on the websites like Facebook or Gmail where you need to authorize yourself by logging in. It just works for the informative websites like Wikipedia.
Conclusion
Fixing 500 Internal Server error is really simple once you know the cause of it. Error logs are the source to find out the server related errors. Once you know the cause, the above instructions will help you to fix the issue in no time. HTTP Error 500 is the most reported error and it can take hell lot of time in solving in case if you are non-techie. Just make sure you follow all the given fixes in-order to quickly fix the 500 Errors if you are Webmaster or the normal browsing user.
Source: https://howbyte.com/fix-500-internal-server-error-or-http-error-500/
Blog Categories
Recent Articles
- Part 6: Create your own Registration System using PHP and MySql
- Part 5: Create your own Registration System using PHP and MySql
- Part 4: Create your own Registration System using PHP and MySql
- Part 3: Create your own Registration System using PHP and MySql
- Part 2: Create your own Registration System using PHP and MySql
- Part 1: Create your own Registration System using PHP and MySql