- Setting Up Database
- Please open localhost/phpmyadmin and create a new database (here I named it regis)
- Create a new table with the name users
- Create a column with “id”, “username”, “email”, “password”, “name”. On id add primary_key, auto_increment. This can be created using 4. phpmyadmin or SQL code, it’s up to you which one you want to create
- Connect the database created with PHP with the name “config.php” so that the database can be connected and can be used.
- Open localhost:8000/config.php, if there is no error then the database configuration with PHP has been successful, if there is an error it is possible that there is a writing error or missing a semicolon.
- Creating the main page
- Create a PHP file with the name index.php , this page serves as a landing page, it only contains HTML and styles.
- Create the display as you wish with the login and register buttons for easy user interface.
- Connect register button with href to register.php
- Go to localhost:8000/index.php .
- Creating a register feature with PHP
- Create a register.php file
- Connect register.php with config.php with the function require_once(); so that the code in config.php can be used in register.php
- Create code to save the database that will be input by the user
- Perform filters and encryption of the inputted data, this serves so that hackers cannot easily attack your website.
- Passwords do not need to be filtered so that users can use symbols to enter passwords so that passwords are more secure
- After filtering, then create a query with the object $db, :name, :username, :email, :password are placeholders. The goal is to avoid SQL Injection attacks.
- After that, we bind the parameters or fill the placeholders with the values we get from the filter results.
- Execute the query with $saved = $stmt->execute($params); , this execution will return true if successful.
- Then create a form to register with the attribute action=”” which will be sent to the website itself, namely register.php .
- Website registration is ready to use
- Conclusion and Closing
In a good website, of course, we need to register and login so that users can interact with further website features, it can also be for admins who want to access the admin page.
The need for digital IT is needed in daily activities, Bead IT Consultant is the right choice as your partner, visit our website by clicking this link: www.beadgroup.com