Skip to content

Commit

Permalink
Merge pull request #1 from SAURABHBHAKUNI/SAURABHBHAKUNI-patch-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
SAURABHBHAKUNI authored Dec 7, 2023
2 parents 25479a7 + 127a4e1 commit 42504e6
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 0 deletions.
15 changes: 15 additions & 0 deletions connection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
error_reporting(E_ALL);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "responsiveform";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
echo"Connectin failed";
}
else{
// echo "Connection ok";
}
?>
63 changes: 63 additions & 0 deletions display.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<html>
<head>
<title>Display</title>
<style>
body{
background: #D071f9;
}
table{
background-color: white;
}
</style>
</head>
</html>
<?php
include("connection.php");
error_reporting(E_ALL);

$query = "select * from form";
$data = mysqli_query($conn , $query);

$total = mysqli_num_rows($data);



//echo $total;
if($total != 0)
{
?>

<h2 align="center"><mark>Display all records</mark></h2>
<center><table border="1" cellspacing="7" width="85%">
<tr>
<th width="10%">First Name</th>
<th width="10%">Last Name</th>
<th width="10%">Gender</th>
<th width="20%">Email</th>
<th width="10%">Phone</th>
<th width="25%">Address</th>
</tr>

<?php
while($result = mysqli_fetch_assoc($data))
{
echo " <tr>
<td>".$result["fname"]."</th>
<td>".$result["lname"]."</td>
<td>".$result["gender"]."</td>
<td>".$result["email"]."</td>
<td>".$result["phone"]."</td>
<td>".$result["address"]."</td>
</tr>
";
}
}
else
{
echo "No record found";
}

?>
</table>
</center>

102 changes: 102 additions & 0 deletions form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
error_reporting(E_ALL);
include("connection.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>School Registration Form</title>
</head>
<body>
<div class="container">
<form action="#" method="POST">
<div class="title">
Registration Form
</div>
<div class="form">
<div class="input_field">
<label for="first_name">First Name</label>
<input type="text" id="first_name" class="input" name="fname" required>
</div>
<div class="input_field">
<label for="last_name">Last Name</label>
<input type="text" id="last_name" class="input" name="lname" required>
</div>
<div class="input_field">
<label for="password">Password</label>
<input type="password" id="password" class="input" name="passwd" required>
</div>
<div class="input_field">
<label for="confirm_password">Confirm Password</label>
<input type="password" id="confirm_password" class="input" name="connpasswd" required>
</div>
<div class="input_field">
<label for="gender">Gender</label>
<div class="custom_select" id="gender" required>
<select name="gender" required>

<option>Select</option>
<option>Male</option>
<option>Female</option>
</select>
</div>
</div>
<div class="input_field">
<label for="email_address">Email Address</label>
<input type="text" id="email" class="input" name="email" required>
</div>
<div class="input_field">
<label for="phone_number">Phone Number</label>
<input type="text" id="phone_number" class="input" name="phone" required>
</div>
<div class="input_field">
<label for="address">Address</label>
<textarea id="address" name="address" required></textarea>
</div>
<div class="input_field_terms">
<label class="check">
<input type="checkbox" id="terms" required>
<span class="checkmark"></span>
</label>
<p>Agree to terms and conditions</p>
</div>
<div class="input_field">
<input type="submit" value="Register" class="btn" name="register">
</div>
</form>
</div>
</body>
</html>

<?php
if($_POST['register'])
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$pwd = $_POST['passwd'];
$cpwd = $_POST['connpasswd'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];

// if($fname !="" && $lname !="" && $pwd !="" && $cpwd !="" && $gender !="" && $email !="" && $phone !="" && $address !="")
//{
$query = "INSERT INTO form ('id','fname','lname','passwd','connpasswd','gender','email','phone','address') values('$id','$fname','$lname','$pwd','$cpwd','$gender', '$email','$phone','$address')";
$data = mysqli_query($conn,$query);
if($data)
{
echo "Data Inserted into Database";
}
else{
echo "failed";
}
}
// else
//{
// echo "<script>alert('Please fill the form')</script>";
//}
//}

?>
160 changes: 160 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}

body {
background-color: #d071d0;
padding: 0 10px;
}

.container {
max-width: 500px;
width: 100%;
background-color: white;
margin: 20px auto;
padding: 30px;
box-shadow: 5px 5px 5px rgba(0, 0, 0.5);
}

.container .title {
font-size: 24px;
font-weight: 700;
margin-bottom: 25px;
color: Blue;
text-transform: uppercase;
text-align: center;
}

.container .form {
width: 100%;
}

.container .form .input_field {
margin-bottom: 15px;
display: flex;
align-items: center;
}

.container .form .input_field label {
width: 200px;
margin-right: 10px;
font-size: 14px;
}

.container .form .input_field .input,
.container .form .input_field textarea {
width: 100%;
outline: none;
border: 1px solid #d071d0;
font-size: 15px;
padding: 6px 8px;
border-radius: 5px;
transition: all 0.5s ease;
}

.container .form .input_field textarea {
resize: none;
height: 70px;
}

.container .form .input_field .custom_select {
position: relative;
width: 100%;
height: 37px;
}

.container .form .input_field .custom_select select {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 100%;
border: 1px solid #d071d0;
border-radius: 5px;
outline: none;
}

.container .form .input_field .custom_select::before {
content: "";
position: absolute;
top: 12px;
right: 10px;
border: 8px solid black;
border-color: #d071d0 transparent transparent transparent;
pointer-events: none;
}

.container .form .input:focus,
.container .form .textarea:focus,
.container .form select:focus {
border: 1px solid purple;
}

.container .form p {
font-size: 14px;
color: #757575;
}

.container .form .check {
width: 15px;
height: 15px;
position: relative;
display: block;
cursor: pointer;
}

.container .form .check input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
opacity: 0;
}

.container .form .check .checkmark {
width: 15px;
height: 15px;
border: 1px solid #d071d0;
display: block;
position: relative;
}

.container .form .check .checkmark::before {
content: "";
position: absolute;
top: 1px;
left: 2px;
width: 5px;
height: 2px;
border: 2px solid;
border-color: transparent transparent white white;
transform: rotate(-45deg);
}

.container .form .check input[type="checkbox"]:checked~.checkmark {
background: #d071d0;
}

.container .form .check input[type="checkbox"]:checked~.checkmark:before {
display: block;
}

.container .form .btn {
width: 100%;
padding: 8px 10px;
font-size: 15px;
border: o;
background-color: #d071d0;
color: white;
cursor: pointer;
border-radius: 3px;
outline: none;
}

.container .form:last-child {
margin-bottom: 0;
}

.container .form .btn:hover {
background: purple;
}

0 comments on commit 42504e6

Please sign in to comment.