Professional Documents
Culture Documents
AIM: -
To create login/registration forms for Web Applications using PHP script
To write validation code for fields in the Forms using PHP script
DESCRIPTION: -
In this tutorial we'll create a simple registration and login system using the PHP and MySQL.
This tutorial is comprised of two parts: in the first part we'll create a user registration form,
and in the second part we'll create a login form, as well as a welcome page and a logout
script.
In this section we'll build a registration system that allows users to create a new account by
filling out a web form. But, first we need to create a table that will hold all the user data.
In this section we'll create a login form where user can enter their username and password.
When user submit the form these inputs will be verified against the credentials stored in the
database, if the username and password match, the user is authorized and granted access to
the site, otherwise the login attempt will be rejected.
CODE:-
Register.php
<!DOCTYPE html>
<html>
<body>
<form method="Post">
<center>
</center>
</form>
<?php
if(isset($_POST['submit']))
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "pass@123";
$db = "osc_exp4";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db,"3304") or die("Connect failed: %s\n". $conn ->
error);
$userid=$_POST["ui"];
$pass=$_POST["pass"];
$con_pass=$_POST["conpass"];
$email_id=$_POST["eid"];
VALUES ('".$userid."','".$pass."','".$con_pass."','".$email_id."')";
$result=mysqli_query($conn,$sql);
if($result)
else
?>
Login.php
<!DOCTYPE html>
<html>
<body>
<form method="Post">
</form>
<?php
if(isset($_POST['submit']))
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "pass@123";
$db = "osc_exp4";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db,"3304") or die("Connect failed: %s\n". $conn ->
error);
$userid=$_POST["ui"];
$pass=$_POST["pass"];
$result1=mysqli_query($conn,$sql);
$rows1=mysqli_num_rows($result1);
if($rows1>0)
else
?>
</body>
</html>
Database (phpmyadmin)
OUTPUT: -
Signup Page