Create form using text box, check box, radio button, select, submit button. And display user inserted value in new PHP page || DWPD Sem 5 Practical 16

Gaming Laptop Under 70k

DWPD : Practical 16

 1. Registration Page Script<html>
<head>
<title>Registration</title>
<style>
.main
{
 width:30%;
 margin:2em auto;
 border:2px solid black;
 padding:1em;
}
.main input[type="submit"]
{
 width:95%;
 border:1px solid black;
 padding:.5em;
 margin:.5em;
}
.main input[type="password"]
{
 width:95%;
 border:1px solid black;
 padding:.5em;
 margin:.5em;
}
.main input[type="text"],.main input[type="email"]
{
 width:45%;
 border:1px solid black;
 padding:.5em;
 margin:.5em;
}
</style>
</head>
<body>
<div class="main">

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

 <h2>Student Registration</h2>

  <input type="text" name="fname" placeholder="First Name">
  <input type="text" name="lname" placeholder="Last Name">
  <input type="email" name="email" placeholder="Email">
  <input type="text" name="mobile" placeholder="Mobile">
  <input type="text" name="city" placeholder="City"><br>
<hr>
  Gender<br>
  <input type="radio" name="gender" value="Male">Male<br>
  <input type="radio" name="gender" value="female">Female<br>
<hr>
  Hobbies<br>
  <input type="checkbox" name="hobby[]" value="Cricket">Cricket<br>
  <input type="checkbox" name="hobby[]" value="Football">Football<br>
  <input type="checkbox" name="hobby[ ]" value="Chess">Chess<br>
<hr>
  <input type="Password" name="pass" placeholder="Password"><br>
  <input type="submit" name="submit" value="Register">
 </form>
</div>
</body>
</html>

Output :

 



 2. Welcome Page Script :<?php
 if(isset($_POST['submit']))
 {
  $fn=$_POST['fname'];
  $ln=$_POST['lname'];
  $em=$_POST['email'];
  $mob=$_POST['mobile'];
  $city=$_POST['city'];
  $gender=$_POST['gender'];
  $hobies=$_POST['hobby'];
  $pass=$_POST['pass'];

  echo "First name : $fn <br><br>";
  echo "Last name : $ln <br><br>";
  echo "Email : $em <br><br>";
  echo "Mobile : $mob <br><br>";
  echo "City : $city <br><br>";
  echo "Gender : $gender <br><br>";

  echo "<h3>Hobbies</h3>";

  $i=0;

  while($i<sizeof($hobies))
  {
   echo $hobies[$i]."<br>";

   $i++;
  }
 }
?>

Output :




Comments