Registration and login form in php and mysql with validation code free download

registration and login form in php and mysql with validation code free download step by step.

Login and Signup form using PHP and MySQL with validation

Step 1 : SQL file: For create table

Sql file

CREATE TABLE `signup_master` (
  `ID` int(10) NOT NULL,
  `Member_name` varchar(100) NOT NULL,
  `Profile_name` varchar(100) NOT NULL,
  `Email` varchar(100) NOT NULL,
  `Password` int(100) NOT NULL,
  `File` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Step 2 : connecting database

connection.php

<?php
    $url='localhost';
    $username='itsolutionstuck';
    $password='[email protected]';
    $db_config=mysqli_connect($url,$username,$password,"fsignup_master");
    if(!$db_config){
        die('Could not Connect My Sql:' .mysql_error());
    }
?>

Step 3: getting the values from the user

signup_master.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
<title>Welcome to Member Portal - https://www.itsolutionstuck.com/</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assests/css/style.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

</head>
<body>
<div class="signup-form">
    <form action="signup_master_a.php" method="post" enctype="multipart/form-data">
		<h2>Register</h2>
		<p class="hint-text">Create your account</p>
        <div class="form-group">
			<div class="row">
				<div class="col"><input type="text" class="form-control" name="member_name" placeholder="First Name" required="required"></div>
				<div class="col"><input type="text" class="form-control" name="profile_name" placeholder="Last Name" required="required"></div>
			</div>        	
        </div>
        <div class="form-group">
        	<input type="email" class="form-control" name="email" placeholder="Email" required="required">
        </div>
		<div class="form-group">
            <input type="password" class="form-control" name="pass" placeholder="Password" required="required">
        </div>
		<div class="form-group">
            <input type="password" class="form-control" name="cpass" placeholder="Confirm Password" required="required">
        </div>
        <div class="form-group">
            <input type="file" name="file" required>
            <!-- <input type="submit" name="upload" value="Upload" class="btn"> -->
        </div>        
        <div class="form-group">
			<label class="form-check-label"><input type="checkbox" required="required"> I accept the <a href="#">Terms of Use</a> & <a href="#">Privacy Policy</a></label>
		</div>
		<div class="form-group">
            <button type="submit" name="save" class="btn btn-success btn-lg btn-block">Register Now</button>
        </div>
        <div class="text-center">Already have an account? <a href="signin.php">Sign in</a></div>
    </form>
	
</div>
</body>
</html>

Step 4: A PHP file that process the signup request

signup_master_a.php

<?php
extract($_POST);
include("connection.php");
$sql=mysqli_query($db_config,"SELECT * FROM signup_master where Email='$email'");
if(mysqli_num_rows($sql)>0)
{
    echo "Member Email Id Already Exists"; 
	exit;
}
else(isset($_POST['save']))
{
    $file = rand(1000,100000)."-".$_FILES['file']['name'];
    $file_loc = $_FILES['file']['tmp_name'];
    $folder="upload/";
    $new_file_name = strtolower($file);
    $final_file=str_replace(' ','-',$new_file_name);
    if(move_uploaded_file($file_loc,$folder.$final_file))
    {
        $query="INSERT INTO signup_master(Member_name, Profile_name, Email, Password, File ) VALUES ('$member_name', '$profile_name', '$email', 'md5($pass)', '$final_file')";
        $sql=mysqli_query($db_config,$query)or die("Could Not Perform the Query");
        header ("Location: signin.php?status=success");
    }
    else 
    {
		echo "Error.Please try again";
	}
}

?>

Step 5: getting the values from the user

signin.php

<?php
    session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
<title>Welcome to Member Portal</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assests/css/style.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

</head>
<body>
<div class="signup-form">
    <form action="signinProcess.php" method="post" enctype="multipart/form-data">
		<h2>Sign In</h2>
		<p class="hint-text">Enter Sign In Details</p>
        <div class="form-group">
        	<input type="email" class="form-control" name="email" placeholder="Email" required="required">
        </div>
		<div class="form-group">
            <input type="password" class="form-control" name="pass" placeholder="Password" required="required">
        </div>
		<div class="form-group">
            <button type="submit" name="save" class="btn btn-success btn-lg btn-block">Sign In</button>
        </div>
        <div class="text-center">Don't have an account? <a href="signup_master.php">Register Here</a></div>
    </form>
</div>
</body>
</html>

Step 6: signin process to check valid user or not

signinProcess.php

<?php
session_start();
if(isset($_POST['save']))
{
    extract($_POST);
    include 'connection.php';
    $sql=mysqli_query($db_config,"SELECT * FROM signup_master where Email='$email' and Password='md5($pass)'");
    $row  = mysqli_fetch_array($sql);
    if(is_array($row))
    {
        $_SESSION["ID"] = $row['ID'];
        $_SESSION["Email"]=$row['Email'];
        $_SESSION["Member_name"]=$row['Member_name'];
        $_SESSION["Profile_name"]=$row['Profile_name']; 
        header("Location: welcome.php"); 
    }
    else
    {
        echo "Invalid Email ID/Password";
    }
}
?>

Step 7: welcome page after signin

welcome.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
<title>Welcome to Member Portal - registration and login form in php and mysql with validation code free download</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assests/css/style.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

</head>
<body>
<div class="signup-form">
    <form action="welcome.php" method="post" enctype="multipart/form-data">
		<h2>Welcome</h2>
        <br>

            <?php
				session_start();
				include 'connection.php';
				$ID= $_SESSION["ID"];
				$sql=mysqli_query($db_config,"SELECT * FROM signup_master where ID='$ID' ");
				$row  = mysqli_fetch_array($sql);
            ?>
            
        <img src="upload/<?php echo $row['File'] ?>" height="150" width="150" style="border-radius:50%;display:block;margin-left:auto;margin-right:auto;" />
		<p class="hint-text"><br><b>Welcome </b><?php echo $_SESSION["Member_name"] ?> <?php echo $_SESSION["Profile_name"] ?></p>
        <div class="text-center">Want to Leave the Page? <br><a href="logout.php">Logout</a></div>
    </form>
	
</div>
</body>
</html>

Step 8: Logout from the application

logout.php

<?php
    session_start();
    unset($_SESSION["id"]);
    unset($_SESSION["name"]);
    header("Location:signin.php");
?>

Leave a Reply

Your email address will not be published.