...We are here to say something...

Insert, View, Edit and Delete Record from Database Using PHP and MySQLi

Steps to Create Simple User Registration & Login Script in PHP and MySQLi

Create a Database
Create a Database Table with Following Five Fields:
id, username, email, password, trn_date
Create a Registration Form
Create a Login Form
Connect to the Database by using PHP
Authenticate Logged in User
Create Index Page
Create Dashboard Page
Create a Log Out
Create a CSS File

CREATE DATABASE register;
2. Creating a Database Table
To create table, execute the below query in SQL.

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`trn_date` datetime NOT NULL,
PRIMARY KEY (`id`)
);


CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`trn_date` datetime NOT NULL,
PRIMARY KEY (`id`)
);

3. Creating a Registration Form

Simple create a page with name registration.php and paste the following code in it.




Registration



require('db.php');
// If form submitted, insert values into the database.
if (isset($_REQUEST['username'])){
// removes backslashes
$username = stripslashes($_REQUEST['username']);
//escapes special characters in a string
$username = mysqli_real_escape_string($con,$username);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($con,$email);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con,$password);
$trn_date = date("Y-m-d H:i:s");
$query = "INSERT into `users` (username, password, email, trn_date)
VALUES ('$username', '".md5($password)."', '$email', '$trn_date')";
$result = mysqli_query($con,$query);
if($result){
echo "

You are registered successfully.



Click here to Login
";
}
}else{
?>

Registration












By :Md. Masud Ali Reza

Email : reez
Date/time : 27/01/2019

  ID : 1
  Name : simon
  Email : nhbhuiyn40@gmail.com
  Answer : hi
  Date/Time : 01/02/19 08:19:28

  ID : 2
  Name : Masud
  Email : masud.al@gmail.com
  Answer : Hello Simon what is your problem
  Date/Time : 01/02/19 08:45:53

  ID : 3
  Name : Masud
  Email : masud.al@gmail.com
  Answer : I am here to see your problem, send me now
  Date/Time : 01/02/19 08:51:41

  ID : 4
  Name :
  Email :
  Answer :
  Date/Time : 01/11/19 08:11:22

  ID : 5
  Name :
  Email :
  Answer :
  Date/Time : 25/11/19 08:01:52

  ID : 6
  Name :
  Email :
  Answer :
  Date/Time : 20/12/19 08:03:17

  ID : 7
  Name :
  Email :
  Answer :
  Date/Time : 24/01/20 08:04:09

  ID : 8
  Name :
  Email :
  Answer :
  Date/Time : 23/02/20 08:06:13

  ID : 9
  Name : abonrernasype
  Email : ydwunAssopeshaptapor@livelyl.online
  Answer : buy cbd oil online [url=http://cbdoilwalm.com/ ]cbd oil [/url] hemp cbd buy hemp oil
  Date/Time : 28/02/20 02:12:05

  ID : 10
  Name :
  Email :
  Answer :
  Date/Time : 24/03/20 08:10:02

  ID : 11
  Name :
  Email :
  Answer :
  Date/Time : 23/04/20 08:09:14

  ID : 12
  Name :
  Email :
  Answer :
  Date/Time : 22/06/20 08:04:28


Name :
Email :
Answer :
 

Login