0% found this document useful (0 votes)
153 views

Keshav PHP

This document contains the index and practical details for a practical file on open source technologies using PHP. The index lists 12 practical tasks covering topics like installing XAMPP, designing a calculator program, creating an input form with validation, developing dynamic web pages to display student marks and book details, and connecting forms to a database. The first practical provides step-by-step instructions for installing the XAMPP web server. The other practicals describe developing programs and web pages to demonstrate various PHP features.

Uploaded by

Keshav Thakur
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)
153 views

Keshav PHP

This document contains the index and practical details for a practical file on open source technologies using PHP. The index lists 12 practical tasks covering topics like installing XAMPP, designing a calculator program, creating an input form with validation, developing dynamic web pages to display student marks and book details, and connecting forms to a database. The first practical provides step-by-step instructions for installing the XAMPP web server. The other practicals describe developing programs and web pages to demonstrate various PHP features.

Uploaded by

Keshav Thakur
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/ 37

Mca(4thsem) 1321707

PRACTICAL FILE
OF
Open Source Technologies Using PHP

Submitted by:- Submitted to:-

Keshav Ms. Rubika Walia


Roll No.:- 1321707

Maharishi Markandeshwar Institute of Computer Technology &Business Management


Maharishi Markandeshwar (Deemed to be University)
Mullana –Ambala (Haryana)
(established under Section 3 of the UGC Act, 1956)
(NAAC Accredited Grade ’A++’ University)

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT1


Mca(4thsem) 1321707

INDEX

SR NAME OF PRACTICAL PAGE NO. DATE OF REMARKS


NO. SUBMISSION

1. Installing process of XAMPP or


WAMP web server.
2. Design and develop a program to
create a calculator.
3. Design and develop an input form and
validate the fields.
4. Design and develop a dynamic web
page which accepts the marks of the
students to display the calculated
result with marks and percentage of
the student.
5. Design and develop a dynamic web
page using prompt, alert and confirm
box.
6. Apply the conditional statements of
PHP on program no. 3.
7. Continue the program no. 4 and apply
date and time.
8. Apply various string operations on
input and output of program no. 4.
9. Write a PHP program to demonstrate
the use of array.
10. Design and develop a web page to
capture book details as given below:
i. Name of author.
ii. Title of Book.
iii. Publisher.
iv. Volume.
11. Write a PHP program to read the
employee detail using form
component.
12. Save the information of program no. 4
in the database using PHP.

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT2


Mca(4thsem) 1321707

PRACTICAL - 1

AIM: Installing process of XAMPP or WAMP web server.


STEP 1: Download.

XAMPP is a release made available by the non-profit project Apache Friends.


Versions with PHP 5.5, 5.6, or 7 are available for download on the Apache Friends
website.

STEP 2: Run.exe file.

Once the software bundle has been downloaded, you can start the installation by
double clicking on the file with the ending .exe.

STEP 3: Deactivate any antivirus software.

Since an active antivirus program can negatively affect the installation process, it’s
recommended to temporarily pause any antivirus software until all XAMPP
components have successfully been installed.

STEP 4: Deactivate UAC.

User Account Control (UAC) can interface with the XAMPP installation because it
limits writing access to the C: drive, so we recommend you deactivate this too for the
duration of the installation process.

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT3


Mca(4thsem) 1321707

STEP 5: Start the setup wizard.

After you have opened the .exe file (after deactivating your antivirus program(s) and
taken note of the user account control, the start screen of the XAMPP setup wizard
should appear automatically. Click on ‘Next’ to configure the installation settings.

STEP 6: Choose software components.

‘Select Components’, you have the option to exclude individual components of the
XAMPP software bundle from the installation. But for a full local test server, we
recommend you install using the standard setup and all available components.

STEP 7: Choose the installation directory.

In this next step, you have the chance to choose where you’d like the XAMPP
software packet to be installed. If you opt for the standard setup, then a folder with
name XAMPP will be created under C:\ for you. After you’ve chosen a location, click
‘Next’.

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT4


Mca(4thsem) 1321707

STEP 8: Start the installation process.

Once all the aforementioned preferences have been decided, click to start the
installation. The setup wizard will unpack and install the selected components and
save them to the designated directory. This process can take several minutes in
total. You can follow the progress of this installation by keeping an eye on the green
loading bar in the middle of the screen.

STEP 9: Windows Firewall blocking.

Your Firewall may interrupt the installation process to block the some components of
the XAMPP. Use the corresponding check box to enable communication between
the Apache server and your private network or work network. Remember that
making you XAMPP server available for public networks isn’t recommended.

STEP 10: Complete installation.

Once all the components are unpacked an installed, you can close the setup wizard
by clicking on ‘Finish’. Click to tick the corresponding check box and open the
XAMPP Control Panel once the installation process is finished.

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT5


Mca(4thsem) 1321707

PRACTICAL- 2

AIM: Design and develop a program to create a calculator.


<!DOCTYPE html>

<html>

<head>

<title>JavaSctipt Calculator</title>

<link rel="stylesheet" href="calcss.css">

<script>

functioncalcNumbers(result){

form.displayResult.value = form.displayResult.value + result;

</script>

</head>

<body>

<div class="container">

<form name="form">

<div class="display">

<input type="text" placeholder="0" name="displayResult"/>

</div>

<div class="buttons">

<div class="row">

<input type="button" name="b7" value="7" onClick="calcNumbers(b7.value)">

<input type="button" name="b8" value="8" onClick="calcNumbers(b8.value)">

<input type="button" name="b9" value="9" onClick="calcNumbers(b9.value)">

<input type="button" name="addb" value="+" onClick="calcNumbers(addb.value)">

</div>

<div class="row">

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT6


Mca(4thsem) 1321707

<input type="button" name="b4" value="4" onClick="calcNumbers(b4.value)">

<input type="button" name="b5" value="5" onClick="calcNumbers(b5.value)">

<input type="button" name="b6" value="6" onClick="calcNumbers(b6.value)">

<input type="button" name="subb" value="-" onClick="calcNumbers(subb.value)">

</div>

<div class="row">

<input type="button" name="b2" value="2" onClick="calcNumbers(b2.value)">

<div class="row">

<input type="button" name="b0" value="0" onClick="calcNumbers(b0.value)">

<input type="button" name="potb" value="." onClick="calcNumbers(potb.value)">

<input type="button" name="divb" value="/" onClick="calcNumbers(divb.value)">

<input type="button" class="red" value="="


onClick="displayResult.value=eval(displayResult.value)">

</div>

</div>

</form>

</div>

</body>

</html>

OUTPUT :

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT7


Mca(4thsem) 1321707

PRACTICAL- 3

AIM: Design and develop an input form and validate the fields.

<!DOCTYPE html>
<html>
<head>
<style>
.error {color: #FF0001;}
</style>
</head>
<body>
<?php
$nameErr = $emailErr = $mobilenoErr = $genderErr = $websiteErr = $agreeErr = "";
$name = $email = $mobileno = $gender = $website = $agree = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (emptyempty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = input_data($_POST["name"]);
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only alphabets and white space are allowed";
}
}
if (emptyempty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = input_data($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (emptyempty($_POST["mobileno"])) {
$mobilenoErr = "Mobile no is required";
} else {
$mobileno = input_data($_POST["mobileno"]);
if (!preg_match ("/^[0-9]*$/", $mobileno) ) {
$mobilenoErr = "Only numeric value is allowed.";

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT8


Mca(4thsem) 1321707

}
if (strlen ($mobileno) != 10) {
$mobilenoErr = "Mobile no must contain 10 digits.";
}
}
if (emptyempty($_POST["website"])) {
$website = "";
} else {
$website = input_data($_POST["website"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-
9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
}
if (emptyempty ($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = input_data($_POST["gender"]);
}
if (!isset($_POST['agree'])){
$agreeErr = "Accept terms of services before submit.";
} else {
$agree = input_data($_POST["agree"]);
}
}
function input_data($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Registration Form</h2>
<span class = "error">* required field </span>
<br><br>
<form method="post" action="<?php echo htmlspecialchars($_SERVER[
"PHP_SELF"]; ?>" >

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT9


Mca(4thsem) 1321707

Name:
<input type="text" name="name">
<span class="error">* <?php echo $nameErr; ?> </span>
<br><br>
E-mail:
<input type="text" name="email">
<span class="error">* <?php echo $emailErr; ?> </span>
<br><br>
Mobile No:
<input type="text" name="mobileno">
<span class="error">* <?php echo $mobilenoErr; ?> </span>
<br><br>
Website:
<input type="text" name="website">
<span class="error"><?php echo $websiteErr; ?> </span>
<br><br>
Gender:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
<input type="radio" name="gender" value="other"> Other
<span class="error">* <?php echo $genderErr; ?> </span>
<br><br>
Agree to Terms of Service:
<input type="checkbox" name="agree">
<span class="error">* <?php echo $agreeErr; ?> </span>
<br><br>
<input type="submit" name="submit" value="Submit">
<br><br>
</form>
<?php
if(isset($_POST['submit'])) {
if($nameErr == "" && $emailErr == "" && $mobilenoErr == "" && $genderErr == "" && 
$websiteErr == "" && $agreeErr == "") {
echo "<h3 color = #FF0001> <b>You have sucessfully registered.</b> </h3>";
echo "<h2>Your Input:</h2>";
echo "Name: " .$name;
echo "<br>";

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT10


Mca(4thsem) 1321707

echo "Email: " .$email;
echo "<br>";
echo "Mobile No: " .$mobileno;
echo "<br>";
echo "Website: " .$website;
echo "<br>";
echo "Gender: " .$gender;
} else {
echo "<h3> <b>You didn't filled up the form correctly.</b> </h3>";
}
}
?>
</body>
</html>

Output:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT11


Mca(4thsem) 1321707

PRACTICAL- 4

AIM: Design and develop a dynamic web page which accepts the
marks of the students to display the calculated result with marks
and percentage of the student.
<html>
<body>
<form action="" method="post">
<center>
<table border=0>
<tr>
<td>
Student Name
</td>
<td>
<input type='text' name="name" placeholder="Name of Student">
</td>
</tr>
<tr>
<td>
Marks for Machine Learning
</td>
<td>
<input type='text' name="machinelearning" placeholder="MACHINE LEARNING">
</td>
</tr>
<tr>
<td>
Marks for BlockChain
<td>
<input type='text' name="blockchain" placeholder="BLOCKCHAIN">
</td>
</tr>
<tr>
<td>
Marks for Internet of Things
</td>
<td>
<input type=text name="internetofthings" placeholder="INTERNET OF THINGS">
</td>
</tr>
<tr>
<td>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT12


Mca(4thsem) 1321707

Marks for Open ST using PHP


</td>
<td>
<input type='text' name="php" placeholder="PHP">
</td>
</tr>

</table>
<br>
<br>
<input type='submit' name="submit" value="Result">
</center>
<?php
if(isset($_POST["submit"]))////checking whether the input element is set or not
{
$name=$_POST['name']; //accessing value from 1st text box
$machinelearning=$_POST["machinelearning"]; //accessing value from 2nd text field
$blockchain=$_POST['blockchain']; //accessing value from 3rd text field
$internetofthings=$_POST['internetofthings']; //accessing value from 4th text field
$php=$_POST['php'];//accessing value from 5th text field
$sum=$machinelearning+$blockchain+$internetofthings+$php; //total marks
$totalgrades=$sum/4;
$percentage= ($sum / 400) * 100;
if($totalgrades>=0&&$totalgrades<=50)
$grade="Fail";
if($totalgrades>50&&$totalgrades<=70)
$grade="C";
if($totalgrades>70&&$totalgrades<=80)
$grade="B";
if($totalgrades>80&&$totalgrades<=90)
$grade="A";
if($totalgrades>90)
$grade="E";
echo "<br>";
echo "<font size=4><center>Student is:-".$name."</center><br>";
echo "<font size=4><center>Total marks:-".$sum."</center><br>";
echo "<font size=4><center>Percentage is:-".$percentage."%</center>";
echo "<font size=4><center>Grade is:-".$grade."</center>";
}
?>
</form>
</body>
</html>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT13


Mca(4thsem) 1321707

OUTPUT:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT14


Mca(4thsem) 1321707

PRACTICAL-5

AIM: Design and develop a dynamic web page using prompt, alert
and confirm box.
<!DOCTYPE html>

<html>

<head>

<title>Practical 3</title>

</head>

<body>

<script>

var a = Number(prompt("Enter 1st number: "));

var b = Number(prompt("Enter 2nd number: "));

var c = Number(prompt("1: Addition\n2: Subtraction\n3: Multiplication\n4: Division"));

switch(c){

case 1:

var result = a+b;

document.write(result);

break;

case 2:

var result = a-b;

document.write(result);

break;

case 3:

var result = a*b;

document.write(result);

break;

case 4:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT15


Mca(4thsem) 1321707

var result = a/b;

document.write(result);

break;

</script>

</body>

</html>

Output:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT16


Mca(4thsem) 1321707

PRACTICAL- 6

AIM: Apply the conditional statements of PHP on program no. 3.


<!DOCTYPE HTML>  
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>  
<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["name"])) {
    $nameErr = "Name is required";
  } else {
    $name = test_input($_POST["name"]);
    // check if name only contains letters and whitespace
    if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
      $nameErr = "Only letters and white space allowed";
    }
  }
  
  if (empty($_POST["email"])) {
    $emailErr = "Email is required";
  } else {
    $email = test_input($_POST["email"]);
    // check if e-mail address is well-formed
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
      $emailErr = "Invalid email format";
    }
  }
    
  if (empty($_POST["website"])) {
    $website = "";
  } else {
    $website = test_input($_POST["website"]);
    // check if URL address syntax is valid
    if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT17


Mca(4thsem) 1321707

9+&@#\/%=~_|]/i",$website)) {
      $websiteErr = "Invalid URL";
    }    
  }

  if (empty($_POST["comment"])) {
    $comment = "";
  } else {
    $comment = test_input($_POST["comment"]);
  }

  if (empty($_POST["gender"])) {
    $genderErr = "Gender is required";
  } else {
    $gender = test_input($_POST["gender"]);
  }
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
?>

<h2>PHP Form Validation Example</h2>


<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF
"]);?>">  
  Name: <input type="text" name="name">
  <span class="error">* <?php echo $nameErr;?></span>
  <br><br>
  E-mail: <input type="text" name="email">
  <span class="error">* <?php echo $emailErr;?></span>
  <br><br>
  Website: <input type="text" name="website">
  <span class="error"><?php echo $websiteErr;?></span>
  <br><br>
  Comment: <textarea name="comment" rows="5" cols="40"></textarea>
  <br><br>
  Gender:
  <input type="radio" name="gender" value="female">Female
  <input type="radio" name="gender" value="male">Male

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT18


Mca(4thsem) 1321707

  <input type="radio" name="gender" value="other">Other
  <span class="error">* <?php echo $genderErr;?></span>
  <br><br>
  <input type="submit" name="submit" value="Submit">  
</form>

<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>
</body>
</html>

Output:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT19


Mca(4thsem) 1321707

PRACTICAL-7

AIM: Continue the program no. 4 and apply date and time.
<html>
<body>
<form action="" method="post">
<center>
<table border=0>
<tr>
<td>
Student Name
</td>
<td>
<input type='text' name="name" placeholder="Name of Student">
</td>
</tr>
<tr>
<td>
Marks for Machine Learning
</td>
<td>
<input type='text' name="machinelearning" placeholder="MACHINE LEARNING">
</td>
</tr>
<tr>
<td>
Marks for BlockChain
<td>
<input type='text' name="blockchain" placeholder="BLOCKCHAIN">
</td>
</tr>
<tr>
<td>
Marks for Internet of Things
</td>
<td>
<input type=text name="internetofthings" placeholder="INTERNET OF THINGS">
</td>
</tr>
<tr>
<td>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT20


Mca(4thsem) 1321707

Marks for Open ST using PHP


</td>
<td>
<input type='text' name="php" placeholder="PHP">
</td>
</tr>
</table>
<br>
<br>
<input type='submit' name="submit" value="Result">
</center>
<?php
if(isset($_POST["submit"]))////checking whether the input element is set or not
{
$name=$_POST['name']; //accessing value from 1st text box
$machinelearning=$_POST["machinelearning"]; //accessing value from 2nd text field
$blockchain=$_POST['blockchain']; //accessing value from 3rd text field
$internetofthings=$_POST['internetofthings']; //accessing value from 4th text field
$php=$_POST['php'];//accessing value from 5th text field
$sum=$machinelearning+$blockchain+$internetofthings+$php; //total marks
$totalgrades=$sum/4;
$percentage= ($sum / 400) * 100;
if($totalgrades>=0&&$totalgrades<=50)
$grade="Fail";
if($totalgrades>50&&$totalgrades<=70)
$grade="C";
if($totalgrades>70&&$totalgrades<=80)
$grade="B";
if($totalgrades>80&&$totalgrades<=90)
$grade="A";
if($totalgrades>90)
$grade="E";
echo "<br>";
echo "<font size=4><center>Student is:-".$name."</center><br>";
echo "<font size=4><center>Total marks:-".$sum."</center><br>";
echo "<font size=4><center>Percentage is:-".$percentage."%</center>";
echo "<font size=4><center>Grade is:-".$grade."</center>";
echo "<font size=4><center>".$date = date('m/d/Y h:i:s a', time())."</center>";
}
?>
</form>
</body>
</html>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT21


Mca(4thsem) 1321707

OUTPUT:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT22


Mca(4thsem) 1321707

PRACTICAL-8

AIM: Apply various string operations on input and output of


program no.4.
<html>
<body>
<form action="" method="post">
<center>
<table border=0>
<tr>
<td>
Student Name
</td>
<td>
<input type='text' name="name" placeholder="Name of Student">
</td>
</tr>
<tr>
<td>
Marks for Machine Learning
</td>
<td>
<input type='text' name="machinelearning" placeholder="MACHINE LEARNING">
</td>
</tr>
<tr>
<td>
Marks for BlockChain
<td>
<input type='text' name="blockchain" placeholder="BLOCKCHAIN">
</td>
</tr>
<tr>
<td>
Marks for Internet of Things
</td>
<td>
<input type=text name="internetofthings" placeholder="INTERNET OF THINGS">
</td>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT23


Mca(4thsem) 1321707

</tr>
<tr>
<td>
Marks for Open ST using PHP
</td>
<td>
<input type='text' name="php" placeholder="PHP">
</td>
</tr>

</table>
<br>
<br>
<input type='submit' name="submit" value="Result">
</center>
<?php
if(isset($_POST["submit"]))////checking whether the input element is set or not
{
$name=$_POST['name']; //accessing value from 1st text box
$machinelearning=$_POST["machinelearning"]; //accessing value from 2nd text field
$blockchain=$_POST['blockchain']; //accessing value from 3rd text field
$internetofthings=$_POST['internetofthings']; //accessing value from 4th text field
$php=$_POST['php'];//accessing value from 5th text field
$sum=$machinelearning+$blockchain+$internetofthings+$php; //total marks
$totalgrades=$sum/4;
$percentage= ($sum / 400) * 100;
if($totalgrades>=0&&$totalgrades<=50)
$grade="Fail";
if($totalgrades>50&&$totalgrades<=70)
$grade="C";
if($totalgrades>70&&$totalgrades<=80)
$grade="B";
if($totalgrades>80&&$totalgrades<=90)
$grade="A";
if($totalgrades>90)
$grade="E";
echo "<br>";
echo "<font size=4><center>Student is:-".$name."</center><br>";
echo "<font size=4><center>Total marks:-".$sum."</center><br>";
echo "<font size=4><center>Percentage is:-".$percentage."%</center>";
echo "<font size=4><center>Grade is:-".$grade."</center>";
echo "<font size=4><center>".$date = date('m/d/Y h:i:s a', time())."</center>";
}
?>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT24


Mca(4thsem) 1321707

</form>
</body>
</html

OUTPUT:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT25


Mca(4thsem) 1321707

PRACTICAL-9

AIM: Write a PHP program to demonstrate the use of array.


<?php
$id=range(1,6);
// Same as specifying $id = array(1, 2, 3, 4, 5, 6)
$id1=range(1,8,2);
$id2=range("A","Z",3);
foreach($id as $value)
echo "$value ";
echo "
<br/>";
foreach($id1 as $value)
echo "$value ";
echo "
<br/>";
foreach($id2 as $value)
echo "$value ";
?>

OUTPUT:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT26


Mca(4thsem) 1321707

PRACTICAL-10

AIM: Design and develop a web page to capture book details as


given below:

I. Name of author.
II. Title of Book.
III. Publisher.
IV. Volume.
<?php

$connect = mysqli_connect('localhost', 'shubham', '12345', 'resultapp');

if(isset($_POST['submit'])){

$author = $_POST['author'];

$title = $_POST['title'];

$publisher = $_POST['publisher'];

$volume = $_POST['volume'];

$sql = "INSERT INTO books SET author = '$author', title = '$title', publisher =
'$publisher', volume = '$volume'";

if(mysqli_query($connect, $sql)){

$msg = "Book is issued";

?>

HTML Code:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT27


Mca(4thsem) 1321707

integrity="sha384-
Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/
dAiS6JXm" crossorigin="anonymous">

<title>Registeration Form</title>

</head>

<body>

<div class="jumbotronjumbotron-fluid">

<div class="container">

<h1 class="display-4">Welcome To Library.</h1>

<p class="lead">Please enter the details to issue a book.</p>

</div>

</div>

<div class="container">

<form action="practical10.php" method="POST">

<div class="form-group row">

<label for="author" class="col-sm-4 col-form-label">Name of Author</label>

<input type="text" class="form-control col-sm-6" id="author" name="author" >

</div>

<div class="form-group row">

<label for="title" class="col-sm-4 col-form-label">Book's Title</label>

<input type="text" class="form-control col-sm-6" id="title" name="title">

</div>

<div class="form-group row">

<label for="publisher" class="col-sm-4 col-form-label">Publisher</label>

<input type="text" class="form-control col-sm-6" id="publisher" name="publisher">

</div>

<div class="form-group row">

<label for="volume" class="col-sm-4 col-form-label">Volume</label>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT28


Mca(4thsem) 1321707

<input type="text" class="form-control col-sm-6" id="volume" name="volume">

</div>

<div class="form-group row"></div>

<div class="form-group row"></div>

<button type="submit" class="btnbtn-success btn-lgbtn-block" name="submit">Issue


Book</button>

<div class="form-group row"></div>

<div class="form-group row"></div>

<div class ="form-group row alert alert-success" role="alert">

<?php echo $msg;?>

</div>

</form>

</div>

</body>

</html>

Output:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT29


Mca(4thsem) 1321707

PRACTICAL-11

AIM: Write a PHP program to read the employee detail using form
component.
<!DOCTYPE html>

<html lang="en">

<head>

<title>Employee Details</title>

</head>

<body style="background-color: lightcyan;">

<div class="jumbotronjumbotron-fluid" style="background-color: darkslategray; color:


white;">

<div class="container">

<h1 class="display-4">New Employee Registration.</h1>

<p class="lead">Please fill your details.</p>

</div>

</div>

<div class="container">

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

<div class="form-group row">

<label for="image" class="col-sm-4 col-form-label">Employee Image</label>

<input type="file" class="col-sm-6 form-group" id="empImage" name="empImage">

</div>

<div class="form-group row">

<label for="empId" class="col-sm-4 col-form-label">Employee ID</label>

<input class="form-group col-sm-6" type="text" id="empId" name="empId">

</div>

<div class="form-group row">

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT30


Mca(4thsem) 1321707

<label for="empPass" class="col-sm-4 col-form-label">Set a password</label>

<input class="form-group col-sm-6" type="password" id="empPass"


name="empPass">

</div>

<div class="form-group row">

<label for="empName" class="col-sm-4 col-form-label">Employee Name</label>

<input class="form-group col-sm-6" type="text" id="empName" name="empName">

</div>

<div class="form-group row">

<label for="empEmail" class="col-sm-4 col-form-label">Email</label>

<input class="form-group col-sm-6" type="text" id="empEmail" name="empEmail">

</div>

<div class="form-group row">

<label for="empContact" class="col-sm-4 col-form-label">Contact</label>

<input class="form-group col-sm-6" type="text" id="empContact"


name="empContact">

</div>

<div class="form-group row">

<label for="empAddress" class="col-sm-4 col-form-label">Address</label>

<input class="form-group col-sm-6" type="text" id="empAddress"


name="empAddress">

</div>

<div class="form-group row">

<label for="empDepartment" class="col-sm-4 col-form-label">Department</label>

<select class="form-group col-sm-6" id="empDepartment" name="empDepartment">

<option value="">--------Select -------</option>

<option value="BCA">BCA</option>

<option value="MCA">MCA</option>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT31


Mca(4thsem) 1321707

<option value="B. Tech">B Tech</option>

<option value="M. Tech">M Tech</option>

</select>

</div>

<div class="form-group row">

<label for="empDesignation" class="col-sm-4 col-form-label">Designation</label>

<select class="form-group col-sm-6" id="empDesignation" name="empDesignation">

<option value="">--------Select -------</option>

<option value="Principal">Principal</option>

<option value="Professor">Professor</option>

<option value="Asst. Professor">Asst. Professor</option>

<option value="Clerk">Clerk</option>

</select>

</div>

<div class="form-group row">

<label for="empGender" class="col-sm-4 col-form-label">Gender</label>

<select class="form-group col-sm-6" id="empGender" name="empGender">

<option value="">--------Select -------</option>

<option value="Male">Male</option>

<option value="Female">Female</option>

</select>

</div>

<div class="form-group row"></div>

<div class="form-group row"></div>

<button type="submit" class="btnbtn-primary btn-lg col-sm-4" name="submit"


style="alignment: center">Register</button>

</form>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT32


Mca(4thsem) 1321707

</div>

</body>

</html>

<?php include_once 'extra11.php' ?>

Output:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT33


Mca(4thsem) 1321707

PRACTICAL-12

AIM: Save the information of program no. 4 in the database using


PHP.
<?php include('config.php');?>
<html>
<body>
<form action="" method="post">
<center>
<table border=0>
<tr>
<td>
Student Name
</td>
<td>
<input type='text' name="name" placeholder="Name of Student">
</td>
</tr>
<tr>
<td>
Marks for Machine Learning
</td>
<td>
<input type='text' name="machinelearning" placeholder="MACHINE LEARNING">
</td>
</tr>
<tr>
<td>
Marks for BlockChain
<td>
<input type='text' name="blockchain" placeholder="BLOCKCHAIN">
</td>
</tr>
<tr>
<td>
Marks for Internet of Things
</td>
<td>
<input type=text name="internetofthings" placeholder="INTERNET OF THINGS">
</td>
</tr>
<tr>
<td>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT34


Mca(4thsem) 1321707

Marks for Open ST using PHP


</td>
<td>
<input type='text' name="php" placeholder="PHP">
</td>
</tr>
</table>
<br>
<br>
<input type='hidden' name="id">
<input type='submit' name="submit" value="Result">
</center>
<?php
if(isset($_POST["submit"]))////checking whether the input element is set or not
{
$name=$_POST['name']; //accessing value from 1st text box
$machinelearning=$_POST["machinelearning"]; //accessing value from 2nd text field
$blockchain=$_POST['blockchain']; //accessing value from 3rd text field
$internetofthings=$_POST['internetofthings']; //accessing value from 4th text field
$php=$_POST['php'];//accessing value from 5th text field

$sql = "INSERT INTO student SET


name = '$name',
machinelearning = $machinelearning,
blockchain = $blockchain,
internetofthings = $internetofthings,
php = $php;
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
if ($res == TRUE)
{
$id=$_GET['id'];
$sql1 = "SELECT * FROM student WHERE id=$id";
$res1 = mysqli_query($conn, $sql1);
$count = mysqli_num_rows($res1);
if ($count==1) {
//Get all the data
$row = mysqli_fetch_assoc($res1);
$name = $row['name'];
$machinelearning = $row['machinelearning'];
$blockchain = $row['blockchain'];
$internetofthings = $row['internetofthings'];
$php = $row['php'];
$sum=$machinelearning+$blockchain+$internetofthings+$php; //total marks
$totalgrades=$sum/4;

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT35


Mca(4thsem) 1321707

$percentage= ($sum / 400) * 100;


if($totalgrades>=0&&$totalgrades<=50)
$grade="Fail";
if($totalgrades>50&&$totalgrades<=70)
$grade="C";
if($totalgrades>70&&$totalgrades<=80)
$grade="B";
if($totalgrades>80&&$totalgrades<=90)
$grade="A";
if($totalgrades>90)
$grade="E";
echo "<br>";
echo "<font size=4><center>Student is:-".$name."</center><br>";
echo "<font size=4><center>Total marks:-".$sum."</center><br>";
echo "<font size=4><center>Percentage is:-".$percentage."%</center>";
echo "<font size=4><center>Grade is:-".$grade."</center>";
echo "<font size=4><center>".$date = date('m/d/Y h:i:s a', time())."</center>";
header("location:".SITEURL.'form.php');
}else
{
//redirect to manage category page with session message
$_SESSION['no-category-found'] = "<div class='error'>Category not Found.</div>";
//redirect to manage category
header("location:".SITEURL.'admin/manage-category.php');
}
}
Else
{
("location:".SITEURL.'form.php');
}
}
?>
</form>
</body>
</html>

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT36


Mca(4thsem) 1321707

OUTPUT:

MAHARISHI MAKANDESHWAR INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT37

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy