This tutorial will cover creating a login system with registration upon registering an activation link will be emailed containing a link to activate the account. Once active the user can login, a reset option is available to reset the password.
Using this PHP script is only accept the valid email address. Do you need to validate or verify an email address? To verify the validity of your email address simply enter your email address into the textbox provided and the validation tool will do the rest. Kindly click 'Download Code' below to have this simple tool. Verification code free download. PH7 Social Dating CMS (pH7Builder) ️ pH7CMS is a Professional, Free & Open Source PHP Social Dating Builder Software (primarily designed.
Also ensure your php version is at least 5.3.17 but ideally should be 5.6 or 7
The file structure will be setup as follows:
The database will require a table to store the members, create a table called members:
In the classes folder their are two files: password.php and user.php. password.php is used to provide the same hashing capability that exists within php 5.5 it uses the same function names so versions 5.3 - 5.5 can use the same functions.<
Note on password for php versions less than 5.5
This library requires PHP >= 5.3.7 OR a version that has the $2y fix backported into it (such as RedHat provides). Note that Debian's 5.3.3 version is NOT supported.
user.php is a class that contains methods to return the users hash (hashed password) as well as logging in, checking if a logged in session already exists and logging the user out.
I'll be going through the user.php methods as they are put to use.
Config.php will be included into all pages enable sessions and turn on output buffering this way headers can be used anywhere in the project.
Set the timezone and define the credentials for the database, next attempt to make a new PDO connection if the connection fails display the error and kill the page.
Next include the user class and make an instance of it, pass in the database object to the class to make use of the database.
Next I have a folder called layout in there is a header.php and footer.php these will contain any layout code that will be used on every page, this saves having to include the stylesheet each time.
header.php is a typical header file, notice the title expects a $title variable, this will be created in the pages and made available to this file, also making use of Bootstrap this is optional and is not required.
Next footer.php this simply closed the body and html, that would be a good place for placing tracking code or any javascript includes.
This is the root page the system loads by default, on this page their is a form for users to register to the site, along with links to the login page, if they are already a member. Also if the user is already logged in they will be redirect to the members page.
How these pages start is by including the config file then checking if the user should be redirected or not.
A call is made to the user object $user->is_logged_in() this will return true or false if the user is logged in.
The title and header.php file is also included on every page.
For new registrations display a form consisting of username, email, password and confirm password.
This is a standard form, one thing to note I make use of sticky forms which means if their has been a validation error the fields that have been filled out will be populated again with the supplied data, except for passwords. Username and email would be restored.
This is done by doing an if statement, if the array $error is set meaning it exists then retrain the $_POST
If an error has been created it will be stored in an error array to display them loop through the array:
Once the new registration has been saved the form will post back to the same page appending a $_GET key on the end of the URL the key will be called action it will have a value of joined
(this technique is used through the project)
![]()
The form should only be processed if it has been submitted this can be checked by an if statement:
This way only if the form has been submitted does the validation start and database interactions commence.
The validation used is fairly basic and can be improved upon
This example checks the length of the username if it's less then 3 characters an error is created, if the first check passes the username is looked up to see if it already exists by passing the username to the database if a record is found an error is created.
These check the password to make sure the email has not been used, it's important the email address is only used once, in the event the user wants to reset their password a link will be emailed to that user.
![]()
After the validation if no errors have been created then carry on.
The password provided cannot be stored as it is, that would be a huge security concern instead it's hashed by passing it to the user object inside a password_hash call this returns a hashed password which can then be stored in the database, this way no one can know what the password was apart from the user who entered it.
If your wondering how can the system login a user in without knowing the password; what happens when the user fills in the login form the password they enter is again hashed and then compared with the hash to see if its a match.
We also want to send an activation link to the user when they register to ensure their email address is active, for this we generate an activation code it will be sent in the emails and will form part of a url to validate the email address.
Next the user's details are saved to the database using a prepared statement, the first page of the query tells MySQL what action to perform in this case to add a new row and the table,columns to insert into.
Where their are columns starting with : like :username these are place holders that will be used to bind the username value to $stmt->execute call. This is done to avoid passing user provided data to the query directly and avoid chances of MySQL Injection.
Calling lastInsertId followed by the primary key will return the id of the record just saved, this is needed for the next step.
Next send an email to the newly created user. Two constants defined in config.php will be used here.
DIR - contains the full website address
SITEEMAIL - the email address used for emails
In the body of the email is a link activate.php?x=$id&y=$activasion this link is passing the id of the user $id and also the activation code when the user received this email, clicking the link will activate their account.
The last step is to redirect the page back to itself and adding an action with the value of joined so the page know if to show a success message.
This page checks for the id and activation code being passed from the url (this happens when the user clicks the link from their email).
Once the data has been verified the users record is updated, the column active is changed from the token to hold 'Yes' to say they are active, this will only happen if the id and token passed match what's stored against that user.
Now users can register they need a way to login, start off with a form that expects their username and password.
The login page will be used to show messages if the users account has been activated or password has been changed, the page will know which message to show based on the value contained inside $_GET['action']
Next attempt to log the user in. Collect the username and password from the form pass them to the users object in the login method this internally will fetch the users hash by looking for the username in the database once the hash is returned it's then passed to password_verify if the hash and user's hash match it returns true which in turns sets a session $_SESSION['loggedin'] to true otherwise false is returned.
To log a user out its very easy:
Once the user is logged out redirect them.
Once the user is logged in redirect them to the members only page (optional).
To ensure a user can only access the page if logged in do a check:
In this example their is not a lot to the members page namely:
Every system need the ability to reset a password in case it's forgotten, how this will work is a user enters their email address, a check is made to make sure its belongs to a user.
Next a token is created and saved to the users record, an email is sent to them containing a link to when clicked the token from the link is verified, if it passed the user is provided with a form to enter their new password, its then saved to the database.
This may seem like a long winded approach but it does prevent the password being sent by email which is not recommended.
To start with the form:
If their is an $_GET['action'] show the correct message.
Next process the form ensure the email matches a user:
Create the token
Next update the users record and set resetToken to the value of the token and resetComplete to No that will be needed if the link is clicked and password has been changed. Send an email to the user containing a link that points to resetPassword.php?key=$token passing the token.
First check the token been passed to the page matches a user
If $stop has been set then display that
If no errors have been created show a form to change the password.
Once the form has been submitted validate the data then hash the password update the users row and set resetComplete to Yes to indicate the process is finished if the reset link is clicked again from email the process will be halted.
Email Verification Tool For Php Source Code Free Download Windows 7
That covers the foundations, this can be used as a starting point to build members based sites or even a start to an admin panel.
Home>>Projects
These PHP Projects is combination of Different modules related to different source code and MySql. It‘s involve Planning, designing and implementation.
Project is best if it Fulfill the user requirement . Its take less time during the execution and work smoothly.
Objective of a project should be: Smarter, attractive, innovative, user friendly.
Email Verification Tool For Php Source Code Free Download PcOur Aim to Develop all PHP Projects
Php projectaim is to develop dynamic and attractive web application as per user requirement. Php project most demanding in current corporate market because it more attractive, faster and have best look and feel.
The PHP projects is easy to develop even a user make small modification as comparison to Java/.Net. We can develop best web application with minimum source code.
PHP Project for students available in PHPEmail Verification Tool For Php Source Code Free Download Torrent
Student can free download php project with source code, PHP projects synopsis and Project report with ease of understanding which help the students to give the primary idea before starting of Project.
On our PHP tutorial some projects are given. After time by time We Introduce new projects related to PHP.
PHP projects free download from PHP Tutorial for Students with source code.
Email Verification Tool For Php Source Code free. download fullComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |