0% found this document useful (0 votes)
43 views7 pages

Ayan Tiwari ROLL NO-58072 BSC Hons Computer Science 2 Year

The document contains the PHP code for a user registration form with fields like username, first name, last name, email, password, gender. It connects to a MySQL database called "registration" and checks if the username already exists. If credentials are valid, the user details are inserted into the database table "users". It displays appropriate success/error messages. The form is styled using CSS for visual elements like colors, positioning, transitions etc.

Uploaded by

Ayan Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views7 pages

Ayan Tiwari ROLL NO-58072 BSC Hons Computer Science 2 Year

The document contains the PHP code for a user registration form with fields like username, first name, last name, email, password, gender. It connects to a MySQL database called "registration" and checks if the username already exists. If credentials are valid, the user details are inserted into the database table "users". It displays appropriate success/error messages. The form is styled using CSS for visual elements like colors, positioning, transitions etc.

Uploaded by

Ayan Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Ayan Tiwari

ROLL NO-58072
BSc HONS COMPUTER SCIENCE 2 year

1.

<?php

$response = null;

$conn=mysqli_connect('localhost','root','','registration');

if(!$conn) {

die("Failed to connect to the database : ".mysli_connect_error($conn));

if(isset($_POST['submit'])) {

$uname=$_POST['user'];

$fname=$_POST['fname'];

$lname=$_POST['lname'];

$email=$_POST['email'];

$pwd=$_POST['pwd'];

$pwd1=$_POST['pwd1'];

$gender=$_POST['gender'];
if( empty($uname) || empty($lname) || empty($fname) || empty($email) ||
empty($pwd) || empty($pwd1) || empty($gender) ) {

$response = "<div class = 'showError'> Fill up all the fields !!! </div>";

elseif( $pwd !== $pwd1) {

$response = "<div class = 'showError'> Password did not match !!! </div>";

else{

$sql = " Select username from users where username = '$uname'";

$res = mysqli_query($conn,$sql);

if(mysqli_num_rows($res)>0 ) {

$response = "<div class = 'showError'> Username already Exists !!!


</div>";

else {

$sql = " Insert into


users(username,fname,lname,email,passwd,gender)
values('$uname','$fname','$lname','$email','$pwd','$gender') ";

if(mysqli_query($conn,$sql)) {

$response = "<div class = 'showSuccess'> Registered


Successfully ! </div>";

}
?>

<!DOCTYPE html>

<html>

<head>

<title>Registration Form </title>

<link rel= "stylesheet" type="text/css" href="style.css">

</head>

<body>

<form action = "registration.php" method = "post">

<div class="container">

<input type= "text" class = "field" name="user" placeholder="Username">


<br>

<input type= "text" class = "field" name="fname" placeholder="First Name">


<br>

<input type= "text" class = "field" name="lname" placeholder="Last Name">


<br>

<input type= "text" class = "field" name="email" placeholder="E-Mail"> <br>

<input type= "password" class = "field" name="pwd"


placeholder="Password"> <br>

<input type= "password" class = "field" name="pwd1" placeholder="Confirm


Password"> <br>

<input class = "radio" type= "radio" name="gender" value='M' checked>Male

<input class = "radio" type= "radio" name="gender" value='F'>Female

<input class = "radio" type= "radio" name="gender" value='O'>Other <br>

<button class="button" type= "submit" name="submit">Sign Up</button>

<div><?php if(isset($_POST['submit'])) echo $response; ?></div>

</div>
</form>

</body>

</html>

Style.css
body {

background-image: url("image1.jpg");

background-size: 100%;

.container {

background-image: linear-gradient(red,#333);

margin-top: 150px;

opacity: 0.8;

border-radius: 10px;

box-shadow: 0 0 15px red;

transition: margin-left,margin-right,width;

transition-duration: 2s;

margin-left: 350px;

margin-right: 400px;

padding: 30px 30px;

.container:hover {

margin-left: 0;

margin-right: 0;

width : 95%;
}

.field {

border-radius: 8px;

margin-left: 50px;

width :80%;

margin-bottom: 15px;

box-shadow: 0 0 20px black;

height: 25px;

.radio {

margin-left: 50px;

height: 20px;

.button {

border-radius: 2px;

position: relative;

margin-top: 15px;

background-color: red;

margin-left: 240px;

color: white;

transition: border-radius 2s, transform 2s;

}
.button:hover {

border-radius: 15px;

transform: rotateY(360deg);

.showError {

color: red;

.showSuccess {

color: green;

You might also like