Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create a following web form using HTML5 form elements. You are expected to use the given HTML5 tags. Also try some basic HTML5 validation for email id and password.
- • <form>
- • <fieldset> and <legend> for grouping elements.
- • <input> - textbox, email, date, password, radio button, check box, file uploading.
- • <textarea>
- • <select> and <option> for list
- • <button> - Normal Button and Submit Button
- <html>
- <form>
- <body>
- <fieldset >
- <legend>Personal Info</legend>
- Email:
- <input type="text"><br><br>
- Password:
- <input type="password"><br><br>
- Gender:
- <select name="Gender">
- <option value="male"> Male</option>
- <option value="female">Female</option>
- <option value="others">Others</option>
- </select><br><br>
- Date Of Birth:
- <input type="text" value="dd/mm/yyyy"><br>
- </fieldset>
- <fieldset>
- <legend> Preferences</legend>
- Favourite color:
- <input type="radio" name="color">Blue
- <input type="radio" name="color">Red
- <input type="radio" name="color">Green<br><br>
- Interests:
- <input type="checkbox" name="Interests">News
- <input type="checkbox" name="Interests">Sports
- <input type="checkbox" name="Interests">Entertainment
- <input type="checkbox" name="Interests">Technology<br><br>
- Languages:
- <select multiple name="Languages">
- <option value="English"> English</option>
- <option value="French">French</option>
- <option value="Spanish">Spanish</option>
- <option value="Italian">Italian</option>
- <option value="German">German</option>
- </select><br><br>
- </fieldset>
- <fieldset>
- <legend>Comments</legend>
- <textarea name="message" rows="8" cols="30"></textarea><br><br>
- Upload A File:
- <input type="file"><br><br>
- <input type"submit" value="submit">
- </fieldset>
- </body>
- </form>
- </html>
- Q) Design the following HTML form using CSS properties with given guidelines.
- <html>
- <head>
- <link rel="stylesheet" href="main.css"/>
- </head>
- <form align=center>
- <style>
- body{
- background-color: lightgreen;
- }
- input [type=text]
- select{
- width: 24px;
- padding: 12px 20px;
- border: 1px sea green;
- display: inline-block;
- margin: 8px 0;
- box-sizing: border-box;
- }
- input[type=submit]
- {
- background-color: orange;
- padding: 20px 80px;
- }
- .div1 {
- float: left;
- width: 45%;
- padding: 1px;
- margin-bottom: 10px;
- display: inline-block;
- border: 2px solid green;
- text-align: right;
- font-family: "Times New Roman", Times, serif;
- }
- .labels1{
- width: 45%;
- float: left;
- text-align:right;
- border: solid;
- }
- .inputboxes{
- width: 45%;
- float: left;
- }
- .ros{
- clear: both;
- }
- </style>
- <fieldset style="width: 50%; margin: 0 auto">
- <h1> <p style="color:blue; text-align:center">Course Information</h1>
- <div class="ros">
- <div class="labels1">Name:</div>
- <div class="inputboxes"><input type="text" name="name"></div>
- </div>
- <br>
- <div class="ros">
- <div class="labels1">Email:</div>
- <div class="inputboxes"><input type="email" name="email"></div>
- </div><br>
- <div class="ros">
- <div class="labels1">Gender:</div>
- <div class="inputboxes"><select name="gender">
- <option value="male">Male</option>
- <option value="female">Female</option>
- </select></div></div><br>
- <div class="ros">
- <div class="labels1">
- Date Of Birth:
- </div>
- <div class="inputboxes"><input type="date" value="dd-mm-yyyy">
- </div><br>
- </div>
- <div class="ros">
- <div class="labels1">
- Course Name:
- </div>
- <input type="text"></div><br>
- <div class="ros">
- <div class="labels1">
- Course Code:
- </div>
- <input type="text"></div><br>
- <div class="ros">
- <div class="labels1">
- Slot:
- </div>
- <select name="slot">
- <option value="L5+6">L5+6</option>
- <option value="L7+8">L7+8</option>
- <option value="L1+2">L1+2</option>
- </select></div></div><br>
- <div class="ros">
- <div class="labels1">
- Mobile Number:
- </div>
- <input type="text" name="mobno"></div><br>
- <textarea name="message" rows="8" cols="70">Remarks</textarea><br>
- <input type="submit" value="submit">
- </fieldset>
- </form>
- </html>
- Q)Design the following Form and validate all form components with proper regular expression pattern.
- <html> <head> <style>
- div{
- }
- .div1{
- width: 50%;
- padding: 10px;
- border: 5px solid gray;
- margin: 0 auto;
- border-radius: 45px;
- padding-top: 0;
- background-color: white;
- }
- .div2{
- background-color: blue;
- margin: 0;
- width:100%;
- border-radius: 25px;
- }
- h1{
- color:white;
- margin: 0;
- }
- input[type=text],[type=password]{
- width: 100%;
- padding: 12px 20px;
- margin: 8px 0;
- box-sizing: border-box;
- border: 2px solid gray;
- border-radius: 4px;
- }
- input:required{
- background: url('./icons/symbol.png');
- background-position: right;
- background-repeat: no-repeat;
- }
- input:invalid{
- border-color: darkred;
- border-width: 2px;
- background:;
- background-position: right;
- background-repeat: no-repeat;
- }
- input:valid{
- border-color: green;
- border-width: 100%;
- background: url('./icons/valid.png');
- background-position: right;
- background-repeat: no-repeat;
- }
- </style>
- </head>
- <body bgcolor="grey" >
- <form>
- <div class="div1" align="center">
- <div class="div2"><h1>HTML AND CSS FORM VALIDATION</h1></div><br>
- <div class="input-style"><input type="text" name="firstname" placeholder="Username" pattern="[A-Z]+[A-Za-z0-9]*" required></div><br>
- <div class="input-style"><input type="password" name="password" placeholder="Password" pattern="{8}.*" required></div><br>
- <div class="input-style">
- <input type="text" name="eamilid" placeholder="Email ID" required></div><br>
- <div class="input-style"><input type="text" name="mobile" placeholder="Mobile Number" required></div><br>
- <div class="input-style"><input type="text" name="web" placeholder="Web Address" required></div><br>
- <button type="button" name="signin" value="signin" style="height:50px;width:150px;background-color: blue; color:white">Sign In</button>
- </div>
- </form>
- </html>
- Q) Design the following form using HTML5 and CSS.
- • Validate all fields by using HTML5 pattern attribute
- • Also send the form values to PHP program and display it in table format.
- HTML CODE:
- <html>
- <head>
- <style>
- div
- {
- background-color: lightgrey;
- width: 300px;
- padding: 25px;
- margin-left: 525px;}
- h2
- {
- background-color:darkgreen;
- width: 100%;
- }
- input[type=submit]
- {
- width: 100%;
- background-color: #4CAF50;
- color: white;
- padding: 14px 20px;
- margin: 8px 0;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- }
- input[type=text], select
- {
- width: 100%;
- padding: 12px 20px;
- margin: 8px 0;
- display: inline-block;
- border: 1px solid #ccc;
- border-radius: 4px;
- box-sizing: border-box;
- }
- </style>
- </head>
- <body>
- <div>
- <h2>VIT UNIVERSITY</h2>
- <i>Student Information</i>
- <form action="act7.php" method="get">
- <fieldset>
- <input type="text" name="name" placeholder="Name" required pattern="\w+ \w+"><br>
- <input type="text" name="regno" placeholder="Register Number" "\d{2}\w{3}\d{4}"><br>
- <input type="radio" name="gender" value="male"> Male
- <input type="radio" name="gender" value="female" checked> Female<br>
- <input type="text" name="email" placeholder="E-mail"><br>
- <input type="text" name="nnum" placeholder="Mobile Number" required pattern="\d{10}"><br>
- <select name="branch">
- <option value="CSE">CSE</option>
- <option value="ECE">ECE</option>
- <option value="EEE">EEE</option>
- <option value="MEC">MEC</option>
- </select><br>
- <input type="submit" value="Submit Information">
- </fieldset>
- </form>
- </div>
- </body>
- </html>
- PHP CODE:
- <html>
- <style>
- table, td{
- border: 3px solid black;
- }
- </style>
- <body>
- <table style="border-collapse: collapse;">
- <tr>
- <td>Name</td>
- <td><?php echo $_GET["name"]; ?></td><br>
- </tr>
- <tr>
- <td>Regno</td>
- <td><?php echo $_GET["regno"];?><br></td>
- </tr>
- <tr>
- <td>Gender</td>
- <td><?php echo $_GET["gender"];?></td><br>
- </tr>
- <tr>
- <td>Email</td>
- <td><?php echo $_GET["email"];?><br></td>
- </tr>
- <tr>
- <td>Mobile</td>
- <td><?php echo $_GET["nnum"];?><br></td>
- </tr>
- <tr>
- <td>Branch</td>
- <td><?php echo $_GET["branch"];?></td></tr>
- </table>
- </body>
- </html>
- Q) Write a PHP application to display the students marks and attendance details. Below are the pages in the application:
- The user should not be able to visit home, attendance and marks pages without login. If a user tries to do so, they should be redirected to login page. The marks and attendance should be user specific.
- act9.php:
- <?php
- $conn = new mysqli('localhost' , 'scse', 'scse', 'scse');
- $usr = "Ipsha";
- $pwd = md5("abcd123!");
- $res1 = $conn->query("insert into authenticate values('Ipsha', 'abcd1234!');");
- $res2 = $conn->query("insert into marks values('Ipsha',70,80,80);");
- $res3 = $conn->query("insert into atendance values('Ipsha',75,75,75);");
- if($res1 && $res2 && $res3)
- echo "Success";
- ?>
- act91.php
- <?php
- session_start();
- if(isset($_POST["submitform"]))
- {
- $usr = $_POST["username"];
- $pwd = $_POST["password"];
- $conn = new mysqli('localhost' , 'scse', 'scse', 'scse');
- $sql = "select * from authenticate where username = '$usr'";
- echo $sql;
- if($res = $conn->query($sql))
- {
- echo "hi";
- $row = $res->fetch_assoc();
- echo "hello";
- echo $pwd;
- echo $row["password"];
- //$cpwd = md5($pwd);
- if($pwd == $row["password"])
- {
- echo "hi";
- $_SESSION['user'] = $usr;
- header('Location:act92.php');
- }
- }
- }
- ?>
- <html>
- <head>
- </head>
- <body>
- <form method="post" action="">
- Username:<input type="text" name="username"></input><br>
- Password:<input type="password" name="password"></input><br>
- <input type="submit" name="submitform"></input>
- </form>
- </body>
- </html>
- act92.php
- <?php
- session_start();
- if(!isset($_SESSION["user"]))
- header('location:act91.php');
- ?>
- <html>
- <head>
- </head>
- <body>
- <ul>
- <li><a href="act93.php">Marks</a></li>
- <li><a href="act94.php">Attendance</a></li>
- </ul>
- <footer><a href="act95.php">Logout</a></footer>
- </body>
- </html>
- act93.php
- <?php
- session_start();
- if(!isset($_SESSION["user"]))
- header('location:act91.php');
- ?>
- <html>
- <head>
- </head>
- <body>
- <?php
- $conn = new mysqli('localhost' , 'scse', 'scse', 'scse');
- $usr = $_SESSION["user"];
- $sql = "select * from marks where username = '$usr';";
- if($res = $conn->query($sql))
- {
- $row = $res->fetch_assoc();
- echo "<p>Subject -- Marks</p>";
- foreach($row as $k=>$v)
- echo "<p>".$k." -- ".$v."</p>";
- }
- ?>
- <footer><a href="logout.php">Logout</a></footer>
- </body>
- </html>
- act94.php
- <?php
- session_start();
- if(!isset($_SESSION["user"]))
- header('location:act91.php');
- ?>
- <html>
- <head>
- </head>
- <body>
- <?php
- $conn = new mysqli('localhost' , 'scse', 'scse', 'scse');
- $usr = $_SESSION["user"];
- $sql = "select * from attendance where username = '$usr';";
- if($res = $conn->query($sql))
- {
- $row = $res->fetch_assoc();
- echo "<p>Subject -- Attendance</p>";
- foreach($row as $k=>$v)
- echo "<p>".$k." -- ".$v."</p>";
- }
- ?>
- <footer><a href="logout.php">Logout</a></footer>
- </body>
- </html>
- act95.php
- <?php
- session_start();
- unset($_SESSION['user']);
- session_destroy();
- header('location:act91.php');
- ?>
Add Comment
Please, Sign In to add comment