registration successful message in php

Today we will talk about registration successful message in php. Displaying a notification after a successful registration is extremely important because it lets us know whether our program works well or not. I also provide source code after this article. Therefore if you are not skillful in PHP or you want to edit this source code, you just need to download the code at the end of the article.

Registration successful message in php

PHP is a popular programming language that is loved by lots of people. It also is the language used to create many opening source codes such as Prestashop, Magento, WordPress, etc. PHP in general and source codes include the registration part. Registration successful message in php works depending on the process of the project. Today we give you a simple notification demo.

Preparation

  • Using hosting or server localhost, you could use xampp or similar software that you need.
  • Code editor software, you could use familiar software such as notepad++

Implementation

We start checking the data. During the registration process, if saving the information of the form to the database is successful, there will be a notification for customers to know they have completed registering. About the displaying content, it may be a thanking or others, you just need to edit texts.

Firstly, we create a database which I name “test”. We add table and fields to the database. If you hesitate to do this, you could copy the following code and paste it into sql.

CREATE DATABASE IF NOT EXISTS `test` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `test`;
 
CREATE TABLE IF NOT EXISTS `users`(
`id`int(11) NOT NULL AUTO_INCREMENT,
`username`varchar(30) NOT NULL,
`password`varchar(30) NOT NULL,
`name`varchar(255) NOT NULL,
`email`varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
<html>
<head>
</head>
<body>
<?php
$conn = mysqli_connect('localhost','root','','register') or die("cannot connect to database");
mysqli_query($conn,"SET NAMES 'UTF8'");
if (isset($_POST["btn_submit"])) {
$username = $_POST["username"];
$password = $_POST["pass"];
$name = $_POST["name"];
$email = $_POST["email"];
if ($username == "" || $password == "" || $name == "" || $email == "") {
echo "Please enter your infomation";
}else{
$sql="select * from users where username='$username'";
$kt=mysqli_query($conn, $sql);
 
if(mysqli_num_rows($kt)  > 0){
echo "Account is exits";
}else{
$sql = "INSERT INTO users(
username,
password,
name,
email
) VALUES (
'$username',
'$password',
'$name',
'$email'
)";
mysqli_query($conn,$sql);
echo "you have registered";
}
}
}
?>
<form action="#" method="post">
<table>
<tr>
<td colspan="2">Form register</td>
</tr>
<tr>
<td>Username :</td>
<td><input type="text" id="username" name="username"></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" id="pass" name="pass"></td>
</tr>
<tr>
<td>Full name:</td>
<td><input type="text" id="name" name="name"></td>
</tr>
<tr>
<td>Email :</td>
<td><input type="text" id="email" name="email"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="btn_submit" value="register"></td>
</tr>
</table>
</form>
</body>
<style>
form{
width: 300px;
margin: auto;
margin-top: 112px;
border: 1px solid #cdcd;
padding: 10px;
}
</style>
</html>

You should input the right information so that the notification can be displayed. You could check in the database. Below is the written data. Because this is the demo, I do not encode the data. When you apply this to the practical project, you are provided with some functions to encode such as md5, sha, etc by PHP for the purpose of customers’ safety.

Registration successful message in php

We have finished the article which is about Registration successful message in php. The issues related to custom fields,create input, create recaptcha as well as form are interested by many people. PHP language and other programming languages newbies should pay attention to this issue.

Enjoy this blog? Please spread the word :)