Labels

php (34) javascript (30) phpjavascript (29) jquery (23) html (19) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Thursday, February 15, 2018

Simple User Registration Form Using PHP, MySQL

In this tutorial, I am illustrating a simple user registration form. register form is a common need in any kind of web-based application so here is register form using PHP, MySQL, HTML, and CSS.

<html>

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <style>
        body{
            padding:40px;
        }
        .container-one{
            width:340px;
            height:320px;
            border:1px solid black;
            padding-left:60px;
        }
        .btn {
            margin: 5px;
        }
    </style>
</head>

<body>

<h3>Register:</h3>

<div class="container-one">
    <form method="POST">
        <div class="col-md-5">
            First Name <input type="text" name="FirstName">
        </div>
        <div class="col-md-5">
            Last Name <input type="text" name="LastName">
        </div>
        <div class="col-md-2">
            Email <input type="text" name="Email">
        </div>
        <div class="col-md-3">
            Password <input type="password" name="Password">
        </div>
        <div class="col-md-2">
            City <input type="text" name="City">
        </div>
        <div class="col-md-2">
     <input type="submit" name="Submit" value="Submit" class="btn">
        </div>
    </form>
</div>

</body>
</html>
<?php
$DatabaseServer = "localhost";
$DatabaseUsername = "root";
$DatabasePassword = "root";
$DatabaseName = "demo";

$Connection = mysqli_connect($DatabaseServer,
 $DatabaseUsername, $DatabasePassword, $DatabaseName);
if ($Connection === false) {
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
if (isset($_POST['Submit'])) {
    $FirstName = $_POST['FirstName'];
    $LastName = $_POST['LastName'];
    $Email = $_POST['Email'];
    $Password = $_POST['Password'];
    $City = $_POST['City'];
    $SQL = "INSERT INTO user 
(FirstName, LastName, Email, Password, City) 
VALUES ('$FirstName', '$LastName', '$Email', '$Password', '$City')";
    $result = mysqli_query($Connection, $SQL);
}
?>
Output:

More Posts

FOLLOW