user-registration-form

User Registration Form Using PHP & HMTL

Hello Friends,

In this blog post, I will explain to you how to make a simple user registration form using PHP?

Registration form is very important function when you have user account facility on your website,

whether it is for subscription based service or selling a product.

In this Registration for User will enter the username and password in a form and will submit their data to your database.

This will help them to login into their account on your website as their username and database will be stored in your database.

You can see the below image for the same.

regis2


Software used for building this functionality is given below:

Install NetBeans IDE
Install Xampp Server


What is the procedure for making this registration functionality?

this is a very simple functionality, you just need to follow the step by step procedure given below.

First, open the Netbeans IDE.

Start the Apache server and MySql server using Xampp.

If you don’t know how to start Xampp Server then please go through this link.

Now create a database name as a test.

Create a table name as login with two fields, username, and password.

Now create a new project in your NetBeans IDE as User_Registration though you can have named as per your wish.

Now create few more file as shown in the below image.

regis1

Once you create all the file then just copy and paste the below code one by one in the respective files.

index.php:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="formregister.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h3>Registration Form</h3>
<form action="#" method="get" id="registerform">
<input type="text" name="username" placeholder="UserName"></input><br/>
<input type="password" name="password" placeholder="PassWord"></input><br/>
<input type="submit" name="submit" value="Submit"></input>
</form>

<?php
if (isset($_GET['submit'])) {
$con = mysql_connect("localhost", "root", "");
//Selecting Database
$db = mysql_select_db("test", $con);

$username = $_GET['username'];
$password = $_GET['password'];

if($username==""||$password=="")
{
echo"Please fill all the fields";
}
else{

$query=mysql_query("insert into login (username, password) values ('$username','$password')");
echo"Your data has been submitted successfully";

mysql_close($con); // Closing the connection
}

}
?>
</body>
</html>

formregister.css:

#registerform{
text-align:center;
border:1px solid #ccc;
width:300px;
padding:0 50px 15px;
margin-top:20px;
box-shadow:0 0 15px;
border-radius:6px;
float:left;
background-color: lightgray;
margin-left: 475px;

}
input[type="submit"]{
width:100%;
padding:10px 45px;
background-color:#2BC1F2;
border:none;
color:#fff;
font-size:18px;
font-weight:700;
cursor:pointer;
font-family: 'Spectral', serif;
margin-left:10px;

}
input[type="text"]{
width:100%;
margin-top:10px;
height:35px;
margin-bottom:25px;
padding:10px;
border:3px solid darkslateblue;
}
input[type="password"]{
width:100%;
margin-top:10px;
height:35px;
margin-bottom:25px;
padding:10px;
border:3px solid darkslateblue;

}
h3{
text-align: center;
}

Now run your project and you will get a registration form ready for your users.


In a case of any queries, you can write us at anurag@a5theory.com we will get back to you ASAP.

Hope! you would have enjoyed this post.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!

php-loginform-session

Login Form: Simple PHP Login Form With Session.

Hello Friends,

In this blog post, I will let you know how to make a simple login form with a session using PHP?

Login is the very important facility in any kind of form.

it provides an authentication and authorization to both user and owner.

If you are selling a product or running a subscription base service then it becomes very important to have a login form so that

we could maintain our user profile and a user can explore in the domain of their account without touching the other’s data.

In this function, you will see a login form and when you will enter the username and password then you will be redirected to your account or profile with a session created.

In your account, you will get the option for logout. When you will click the logout option then you will come out of your profile with a session destroyed. See the below image for the same.


login1

login2


What is the procedure to make a simple login form in PHP?

You just need to follow the below step by step procedure for the same.

First, you should know the software used for developing this functionality. Though you can use the either the same or similar software for the same.

Install NetBeans IDE
Install Xampp Server

Start Apache server and SQL server using your XAmpp.

If you don’t know how to start the Xampp server then you can go with this link.

Now open PHP MyAdmin and create a database name as a test and then create a table login. You can also use the below script for creating the database.

Now insert one record as username and password in the database so that it can be used while you will make login to your form.

Open the NetBeans IDE and create a project named as Login _Form, though you can keep any other name as per your wish.

Now the create few files as shown in the below image in the source folder of your project.

Once you create all the files then copy and paste the code one by one in the respective files which are given below.


index.php:

<?php
include('login.php'); // Here we are including login script

if(isset($_SESSION['login_user'])){
header("location: myprofile.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Form in PHP with Session</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="main">
<h1>PHP Login Session Example</h1>
<div id="login">
<h2>Login Form</h2>
<form action="" method="post">
<label>UserName :</label>
<input id="name" name="username" placeholder="username" type="text">
<label>Password :</label>
<input id="password" name="password" placeholder="**********" type="password">
<input name="submit" type="submit" value=" Login ">
<span><?php echo $error; ?></span>
</form>
</div>
</div>
</body>
</html>

login.php:

<?php
session_start(); // Here we are starting a session
$error=''; // This variable is to store the error message.
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else
{
// Here define username and password.
$username=$_POST['username'];
$password=$_POST['password'];
// Here we are establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "root", "");
// This is to protect MySQL injection for security purpose.
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Selecting Database
$db = mysql_select_db("test", $connection);
// This SQL query will fetch the registered user and will match the login user.
$query = mysql_query("select * from login where password='$password' AND username='$username'", $connection);
$rows = mysql_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user']=$username; // Here we are Initializing Session
header("location: myprofile.php"); // Redirection To Other Page
} else {
$error = "Username or Password is invalid";
}
mysql_close($connection); // Closing Connection
}
}
?>

session.php:

<?php
// Establishiing the server connection by passing server id and password
$connection = mysql_connect("localhost", "root", "");
// Selecting Database
$db = mysql_select_db("test", $connection);
session_start();// Starting Session
// Storing Session
$user_check=$_SESSION['login_user'];
// This sql query will fetch all the user information.
$ses_sql=mysql_query("select username from login where username='$user_check'", $connection);
$row = mysql_fetch_assoc($ses_sql);
$login_session =$row['username'];
if(!isset($login_session)){
mysql_close($connection); // Closing Connection
header('Location: index.php'); // Redirection To Home Page
}
?>

myprofile.php:

<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Your Home Page</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="profile">
<b id="welcome">Welcome : <i><?php echo $login_session; ?></i></b>
<b id="logout"><a href="logout.php">Log Out</a></b>
</div>
</body>
</html>

logout.php:

<?php
session_start();
if(session_destroy()) // Here we are destrying all the session.
{
header("Location: index.php"); // Redirecting To Home Page
}
?>

style.css:

@import url('https://fonts.googleapis.com/css?family=Spectral');
/*----------------------------------------------
CSS Settings For HTML Div ExactCenter
------------------------------------------------*/
#main {
width:960px;
margin:50px auto;
font-family: 'Spectral', serif;
}
span {
color:red
}
h2 {
background-color:#e4e3ea;
text-align:center;
border-radius:10px 10px 0 0;
margin:-10px -40px;
padding:15px;
color: rebeccapurple;
}
hr {
border:0;
border-bottom:1px solid #ccc;
margin:10px -40px;
margin-bottom:30px
}
#login {
width:300px;
float:left;
border-radius:10px;
font-family:raleway;
border:2px solid #ccc;
padding:10px 40px 25px;
margin-top:70px;
background-color: #d7d6dc;
}
input[type=text],input[type=password] {
width:99.5%;
padding:10px;
margin-top:8px;
border:1px solid #ccc;
padding-left:5px;
font-size:16px;
font-family: 'Spectral', serif;
}
input[type=submit] {
width:100%;
background-color:#999aca;
color:#fff;
border:2px solid #a7a6d2;
padding:10px;
font-size:20px;
cursor:pointer;
border-radius:5px;
margin-bottom:15px
}
#profile {
padding:50px;
border:1px dashed grey;
font-size:20px;
background-color:#DCE6F7
}
#logout {
float:right;
padding:5px;
border:dashed 1px gray
}
a {
text-decoration:none;
color:#6495ed
}
i {
color:#6495ed
}

In a case of any queries, you can write us at anurag@a5theory.com we will get back to you ASAP.

Hope! you would have enjoyed this post.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!

xampp-server

XAMPP SERVER: What is Xampp Server?

Hello Friends,

In this blog post, I will let you know about Xampp server.

You would have listened to the name of the web server and localhost or local server.

As live web server keeps our website data and files, in a similar way Xampp stores your web pages and files on the local server.

This is a local server which you can install on your local system and can perform the testing on your website before it actually uploading to the web.



What is Xampp server?

Xampp is known as a local web server which provides the suitable environment for PHP, SQL and more…

See the XAMPP description below.

X: Cross platform- Xampp is cross-platform.

Cross-platform means it can be run on any computer machine and with any operating software or it is compatible with all types of computer hardware and software.

A: Apache server: Xampp ncludes Apache server.

This server is required for running most of the application or software like PHP. It is the most usable webserver software across the world.
It is popular because it is quick, reliable and safe. It is open source and free to use.

M: Maria DB – Xampp supports Maria DB.
Maria DB is the popular database server which is open source and developed by original developers of MySQL.

P: PHP– Xampp support the PHP.

PHP stands for PHP Hypertext Processor(earlier it was known as Personal Home Page), It provides an environment for web development.
This is a server-side scripting language.

P: PERL – Xampp support PERL.

PERL(Practical extraction and reporting language) is a high-level general purpose programming language. It is used in developing the web application.


Have you tried this Amazing & Cheap email cleaning service
emailquickfixpromo1


What does Xampp server include…..?

When you start the Xampp server you see the various stuff explained below.

Apache: This is the most popular web server on the web which actually processes and supply the web content to the computer.

MySQL: This functionality would be encapsulated with all the simple and complicated web application.

This is always there for storing the data. MYSQL is the most popular database to work with. It is a free & open source.

You can easily learn MYSQL associated with XAMPP package and well work with PHP.

Filezilla: It is an FTP(file transfer protocol) server used for making smooth file transfer from local server to live server and vice…

Mercury: it is a simple and open source mail server.

Tomcat: It is a freeware Java servlet for serving the Java application.

 

Apache and MYSQL are the best stuff for the beginners especially working with PHP application.

Though it is enough to play around these two until you are working on localhost.



What is the benefit of Xampp server with localhost?

Both servers have their equal importance, as a live server is used to keep our website data and make it live or visible to all the users across the world.

But we can’t perform more testing work on the live server as it can create a massive traffic and load to the live server thus may result in a hang or stuck our website. So for testing work or update work for our website we need a server similar to our live server(live server also have Xampp or Wamp installed). So Xampp is the best option for achieving this.

So for testing work or update work for our website we need a server similar to our live server(live server also have Xampp or Wamp installed). So Xampp is the best option for achieving this.

It is an open source software and you can easily download and install it on your local machine.
Once you install this on your local machine then you can perform any number of test or updations to your website.


How to install the Xampp Server?

It is very simple to install the Xampp server.

You can download the setup over the internet and after downloading the setup you can easily install it on your local machine.

You can go through the below links for the same. Just copy the link and paste in the browser.

https://www.apachefriends.org/download.html

http://filehippo.com/download_xampp/

https://xampp-windows.en.softonic.com/download


How to start Xampp Server?

Once your download is complete just open the Xampp control panel and start the service as per your requirement.See the below image for the same.

php6

Note: This is the case when you are using Skype. Ignore this if you are not using.

 Xampp and Skype run on the same port so remember to close the process for Skype in a case if it is running in the background else your Xampp will not start properly.

You can close it just go to the task bar(alt+ctrl+delete) and end the Skype process.


In a case of any queries, you can write us at anurag@a5theory.com we will get back to you ASAP.

Hope! you would have enjoyed this post.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!