0% found this document useful (0 votes)
18 views8 pages

Het PHP 3

Uploaded by

hetmp2006
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)
18 views8 pages

Het PHP 3

Uploaded by

hetmp2006
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/ 8

22171341092 practical:-3 php

Practical:-3.1
Aim:- Create student registration form using text box, check box, radio
button, select, submit button. And display user inserted value in new PHP
page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body
{
margin: 20px;
}
input
{
background-color: white;
background-position: 10px 10px;
background-repeat: no-repeat;
padding-left: 40px;
margin: 5px;
}
input[type=text]:focus {
border: 3px solid green;
}
.myDiv {
border: 5px outset black;
background-color:palevioletred;
text-align: center;
margin: 20px;
}
</style>
</head>
<body>
<?php
if(isset($_GET['s'])){
?>
<div class="myDiv">

<?php
$hobby=$_GET['h'];
echo"Welcome..." . $_GET['un'];
echo"</br>Email :". $_GET['e'];
echo"</br>en.number :". $_GET['en'];
echo"</br>Your DOB is :". $_GET['DOB'];
22171341092 practical:-3 php

echo"</br>Your Address :". $_GET['address'];


echo"</br>your gender is :". $_GET['g'];
echo"</br>Your Branch is :". $_GET['b'];
echo "</br>Your hobbies are ";
foreach($hobby as $hobbies){
echo $hobbies ." ";
}
?>
</div>
<?php
}
?>
<form>
<input type="text" name="un" placeholder="Enter your name"></br>
<input type="email" name="e" placeholder="enter your email"><br/>
<input type="number" name="en" placeholder="Enter your enrollment no"></br>
DOB:<input type="date" name="DOB"></br>
<textarea name="address" placeholder="enter your address"></textarea></br>
<input type="radio" name="g" value="Male">male
<input type="radio" name="g" value="Female">female</br>
branch<select name="b" id="">
<option value="ce">ce</option>
<option value="it">it</option>
<option value="mc">mc</option>
</select><br/>
<input type="checkbox" name="h[]" value="travelling">travelling
<input type="checkbox" name="h[]" value="reading">reading
<input type="checkbox" name="h[]" value="sleeping">sleeping<br/>
<input type="Submit" name="s" >
<input type="reset">
</form>
</body>
</html>
22171341092 practical:-3 php

Output:-

Practical:-3.2
Aim:- Create Website Registration Form using text box, check box, radio
button, select, submit button. And display user inserted value in same PHP
page.(PHP_SELF).

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website registration Form</title>
<style>
body
{
margin: 30px;
}
input
{
background-color: white;
background-position: 10px 10px;
background-repeat: no-repeat;
padding-left: 40px;
margin: 2px;
}
input[type=text]:focus {
border: 3px solid green;
}
.myDiv {
22171341092 practical:-3 php

border: 5px outset black;


background-color:#bdb2ff;
text-align: center;
margin: 20px;
}
</style>
</head>
<body>

<div class="myDiv">

<?php
if($_SERVER['REQUEST_METHOD']=="POST"){
if(isset($_POST['s'])){
$name=$_POST['un'];
$lname=$_POST['un2'];
echo"hello...!!$name $lname";
echo"</br>Email ID:". $_POST['e'];
echo"</br>Your DOB is :". $_POST['DOB'];
echo"</br>Your gender is :". $_POST['g'];
}
}
?>
</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
First Name: <input type="text" name="un" placeholder="Enter your first
name"></br>
Last Name: <input type="text" name="un2" placeholder="Enter your last
name"></br>
Your Email: <input type="email" name="e" placeholder="Enter your email"><br/>
Password: <input type="password" name="p" placeholder="Enter your
password"><br/>
Gender:<input type="radio" name="g" value="Male">male
<input type="radio" name="g" value="Female">female</br>
DOB:<input type="date" name="DOB"></br>
<input type="Submit" name="s" value="Sign Up" >
<input type="reset">
</form>
</body>
</html>

Output:-
22171341092 practical:-3 php

Practical:-3.3
Aim:- : Create employee registration form using text box, checkbox, radio
button, select, submit button. And display user inserted value in new PHP
page using $_REQUEST[].
<?php
if (isset($_REQUEST['submit'])) {
echo "<h2>Employee Registration Details</h2>";
echo "Name: " . $_POST['name'] . "<br>";
echo "Employee ID: " .$_POST['empid'] . "<br>";
echo "Email: " . $_POST['email'] . "<br>";
echo "Mobile Number: " . $_POST['mobile'] . "<br>";
echo "City: " . $_POST['city'] . "<br>";
echo "Date of Birth: " .$_POST['dob']. "<br>";
echo "Skills: ";
if (isset($_POST['skills'])) {
echo implode(", ", $_POST['skills']). "<br>";
} else {
echo "None<br>";
}
if (isset($_POST['gender'])) {
echo "Gender: " . $_POST['gender'] . "<br>";
} else {
echo "Gender: Not specified<br>";
}
echo "Department: " . $_POST['department'] . "<br>";
} ?>

<div class="form-container">
<h2>Employee Registration Form</h2>
<form action="ref33.php" method="post">
<label for="name">Full Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="empid">Employee ID:</label>
22171341092 practical:-3 php

<input type="text" id="empid" name="empid"><br><br>


<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<label for="mobile">Mobile Number:</label>
<input type="text" id="mobile" name="mobile"><br><br>
<label for="city">City:</label>
<input type="text" id="city" name="city"><br><br>
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob"><br><br>
<label>Skills:</label><br>
<input type="checkbox" name="skills[]" value="HTML"> HTML<br>
<input type="checkbox" name="skills[]" value="CSS"> CSS<br>
<input type="checkbox" name="skills[]" value="JavaScript">
JavaScript<br><br>
<label>Gender:</label><br>
<input type="radio" id="male" name="gender" value="Male">
<label for="male" style="display:inline;">Male</label><br>
<input type="radio" id="female" name="gender" value="Female">
<label for="female"
style="display:inline;">Female</label><br><br>
<label for="department">Department:</label>
<select id="department" name="department" required>
<option value="">Select</option>
<option value="HR">HR</option>
<option value="IT">IT</option>
<option value="Finance">Finance</option>
</select><br><br>
<button type="submit" name="submit">Submit</button>
</form>
</div>
</body>
</html>

Output:-
22171341092 practical:-3 php

Practical:-3.4
Aim:- Create PHP script that can upload any 3 type of file to the specific
folder.

<!DOCTYPE html>
<html>
<head>
<title>file upload p34</title>
<style>
div{
position:absolute;
top:50px;
right: 90px;;
width:200px;
height:150px;
padding-left:5px; }
</style>
</head>
<body>
<div>
<?php
if (isset($_POST['submit'])) {
if(isset($_FILES['file1']['tmp_name']))
{
move_uploaded_file($_FILES['file1']['tmp_name'],"../../img/". $_FILES['file1']['name']);
echo "<h3> File uploaded </h3>";
}
else
{
echo "<h3>ERROR...!!! in file upload</h3>";
}
echo "Full Name: " . $_POST['name'] . "<br>";
echo "Username: " . $_POST['username'] . "<br>";
echo "Email: " . $_POST['email'] . "<br>";
echo "Gender: " . $_POST['gender'] . "<br>";
}
?>
</div>
<!-- Registration Form -->
<form method="post" enctype="multipart/form-data">
<label>Full Name:</label>
<input type="text" name="name"><br><br>
<label>Username:</label>
<input type="text" name="username"><br><br>
<label>Email:</label>
22171341092 practical:-3 php

<input type="email" name="email"><br><br>


<label>Gender:</label><br>
<input type="radio" name="gender" value="Male">
<label>Male</label><br>
<input type="radio" name="gender" value="Female">
<label>Female</label><br><br>
<input type="file" name="file1" /><br><br>
<input type="submit" name="submit" >
</form>
</body>
</html>

Output:-

You might also like