0% found this document useful (0 votes)
20 views3 pages

PHP Assignment Answers

The document contains several PHP scripts for various functionalities, including checking if a number is even or odd, and creating registration forms for faculty and student projects. It includes HTML forms for user input and PHP scripts for handling form submissions, displaying the submitted data. Additionally, it provides an example of variable declaration in PHP with rules for naming variables.

Uploaded by

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

PHP Assignment Answers

The document contains several PHP scripts for various functionalities, including checking if a number is even or odd, and creating registration forms for faculty and student projects. It includes HTML forms for user input and PHP scripts for handling form submissions, displaying the submitted data. Additionally, it provides an example of variable declaration in PHP with rules for naming variables.

Uploaded by

subhashhajare45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

PHP Script to Check Whether a Number is Even or Odd

<?php
$number = 15; // You can change the number

if ($number % 2 == 0) {
echo "$number is Even";
} else {
echo "$number is Odd";
}
?>

2. Faculty Registration Form for Development Program (faculty_form.php)

<!DOCTYPE html>
<html>
<head>
<title>Faculty Registration Form</title>
</head>
<body>
<h2>Faculty Development Program Registration</h2>
<form method="POST" action="faculty_submit.php">
Name: <input type="text" name="name" required><br><br>
College Name: <input type="text" name="college" required><br><br>
Mobile No: <input type="text" name="mobile" required><br><br>
Email ID: <input type="email" name="email" required><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>

Faculty Registration Form Submission (faculty_submit.php)

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$college = $_POST['college'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];

echo "<h2>Registration Successful!</h2>";


echo "Name: $name<br>";
echo "College: $college<br>";
echo "Mobile No: $mobile<br>";
echo "Email ID: $email<br>";
}
?>

3. Student Project Registration Form (student_form.php)


<!DOCTYPE html>
<html>
<head>
<title>Student Project Registration</title>
</head>
<body>
<h2>Project Competition Registration</h2>
<form method="POST" action="student_submit.php">
Student Name: <input type="text" name="student_name" required><br><br>
College Name: <input type="text" name="college_name" required><br><br>
Mobile No: <input type="text" name="mobile_no" required><br><br>
Email ID: <input type="email" name="email" required><br><br>
Project Title: <input type="text" name="project_title" required><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Student Project Submission Handling (student_submit.php)

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$student_name = $_POST['student_name'];
$college_name = $_POST['college_name'];
$mobile_no = $_POST['mobile_no'];
$email = $_POST['email'];
$project_title = $_POST['project_title'];

echo "<h2>Submission Received!</h2>";


echo "Student Name: $student_name<br>";
echo "College Name: $college_name<br>";
echo "Mobile No: $mobile_no<br>";
echo "Email ID: $email<br>";
echo "Project Title: $project_title<br>";
}
?>

4. PHP Variable Declaration Example

<?php
// Rules for declaring variables in PHP:
// 1. Start with $ sign.
// 2. Must start with a letter or underscore (_)
// 3. Cannot start with a number.
// 4. Are case-sensitive.

$studentName = "Alice";
$age = 20;
$_score = 85.5;

echo "<h2>Variable Declaration Example</h2>";


echo "Student Name: $studentName<br>";
echo "Age: $age<br>";
echo "Score: $_score<br>";
?>

You might also like