Vous êtes sur la page 1sur 11

Question No.

1:
Make a Program in Php to differentiate the GET and POST Method.
1: POST:
<html>
<head>
<title></title>
</head>
<body>
<center>
<form method="POST" action="">
Full name: <input type="text" name="fullname" value="">
<br><br>
Class: <input type="text" name="class" value="">
<br><br>
RollNo: <input type="text" name="rollno" value"">
<br><br>
<input type="submit" name="Insert" value="SHOW DATA">
<br><br>
</form>
<?php
$fname="";
$class="";
$roll="";
if(isset($_POST['Insert']))
{
$fname=$_POST['fullname'];
$class=$_POST['class'];
$roll=$_POST['rollno'];
}
echo "The name is ".$fname;
echo "<br>The class is ".$class;
echo "<br>The rollnumber is ".$roll;
?>
</center>
</body>
</html>

2:GET:

<html>
<head>
<title></title>
</head>
<body>
<center>
<form method="GET" action="">
Full name: <input type="text" name="fullname" value="">
<br><br>
Class: <input type="text" name="class" value="">
<br><br>
RollNo: <input type="text" name="rollno" value"">
<br><br>
<input type="submit" name="Insert" value="SHOW DATA">
<br><br>
</form>
<?php
$fname="";
$class="";
$roll="";
if(isset($_GET['Insert']))
{
$fname=$_GET['fullname'];
$class=$_GET['class'];
$roll=$_GET['rollno'];
}
echo "The name is ".$fname;
echo "<br>The class is ".$class;
echo "<br>The rollnumber is ".$roll;
?>
</center>
</body>
</html>
Question No.2:
Make a Student System in php to implement the Following F=things User enter the Student Information
Like Roll No , CNIC , Marks , Subject Name , Student Name , Class , Section and after that when user
clicks on the Insert Button the data will be saved in the Database using Insert Query and after that
display the Data from the database using Select Query.

<html>
<body>
<center>
<H2>Register</H2>
<form method="POST" action="databaseq2.php">
Studentname:<input type="Text" name="sname"/><br><br>
Marks:<input type="Text" name="mark"/><br><br>
Cnic:<input type="Text" name="cnic"/><br><br>
RollNumber:<input type="Text" name="rolno"/><br><br>
SubjectName:<input type="Text" name="subname"/><br><br>
Class:<input type="Text" name="clas"/><br><br>
Section:<input type="Text" name="sec"/><br><br>
<input type="submit" value="insert data" name="Insert"/>
</form>
</center>
</body>
</html>
<?php
if(isset($_POST['Insert']))
{
$x=array("50");
$servername="localhost";
$username="root";
$password="";
$dbname="q2";
$con=mysqli_connect($servername,$username,$password,$dbname);
$Studentname=$_POST['sname'];
$Marks=$_POST['mark'];
$Cnic=$_POST['cnic'];
$RollNumber=$_POST['rolno']
$SubjectName=$_POST['subname'];
$Class=$_POST['clas'];
$Section=$_POST['sec'];
$sql="INSERT INTO
show_record1(Studentname,Marks,Cnic,RollNumber,SubjectName,Class,Section)V
ALUES('$Studentname','$Marks','$Cnic','$RollNumber','$SubjectName','$Class','$S
ection')";
if($con)
{
echo"Connection is establised.";
}
else
{
echo"Connection is not establisehd.";
}

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

echo"Data has been inserted.";


}
else
{
echo"Data is not entered.";
}
if($Marks<$x[0])
{
echo"Fail";
}
else if($Marks>$x[0])
{
echo"Pass";
}
}
?>
Question No.4:
Make a Php function in which user enters the Height and Width of Any shape and if user clicks on
the Calculate Area Button then make a php function to calculate the area using php variables method
used in this program Is POST.
<html>
<body>
<center>
<H2>Calculate area </H2>
<form method="POST">
Enter height<input type="Text" name="he"/>
Enter width<input type="Text" name="w"/>
<input type="Submit" value="Insert data" name="insert"/>

</form>
<?php
function calculate()
{
if(isset($_POST['insert']))
{
$x=$_POST['he'];
$y=$_POST['w'];
$area=($x*$y)/2;
echo"The area is:".$area;
}
}
calculate();
?>
</center>
</body>
</html>

. Question No.5:
Make a Php Based Web Application in which four functionality Like Insert , Update , Delete and Display
the Record Queries will be used and it is upto you that if you want implement this using Proper Design
Like CSS and HTML otherwise it is Not Required

<?php
include("assdata.php");
error_reporting(0);

?>
<html>
<body>
<center>
<form method="Post">
Studentname:<input type="Text" name="sname"/><br><br>
Marks:<input type="Text" name="mark"/><br><br>
Cnic:<input type="Text" name="cnic"/><br><br>
RollNumber:<input type="Text" name="rolno"/><br><br>
SubjectName:<input type="Text" name="subname"/><br><br>
Class:<input type="Text" name="clas"/><br><br>
Section:<input type="Text" name="sec"/><br><br>

<input type="submit" value="insert data" name="Insert"/>


<input type="submit" value="Select" name="select"/>

</form>
<form method="GET">
Studentname:<input type="Text" name="sname"/><br><br>
Marks:<input type="Text" name="mark"/><br><br>
Cnic:<input type="Text" name="cnic"/><br><br>
RollNumber:<input type="Text" name="rolno"/><br><br>
SubjectName:<input type="Text" name="subname"/><br><br>
Class:<input type="Text" name="clas"/><br><br>
Section:<input type="Text" name="sec"/><br><br>
<input type="submit" value="Delete" name="delete"/>
<input type="submit" value="Update" name="update"/>

</form>
</center>
<?php
if(isset($_POST['Insert']))
{
$servername="localhost";
$username="root";
$password="";
$dbname="q2";
$con=mysqli_connect($servername,$username,$password,$dbname);
$Studentname=$_POST['sname'];
$Marks=$_POST['mark'];
$Cnic=$_POST['cnic'];
$RollNumber=$_POST['rolno'];

$SubjectName=$_POST['subname'];
$Class=$_POST['clas'];
$Section=$_POST['sec'];

$sql="INSERT INTO
show_record1(Studentname,Marks,Cnic,RollNumber,SubjectName,Class,Section)VALUES('$Studentname
','$Marks','$Cnic','$RollNumber','$SubjectName','$Class','$Section')";

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

echo"Data has been inserted.";


}
else
{
echo"Data is not entered.";
}

}
?>

<center>
<table border="2px">
<tr>
<td>Studentname</td>
<td>Marks</td>
<td>Cnic</td>
<td>RollNumber</td>
<td>SubjectName</td>
<td>Class</td>
<td>Section</td>
<td colspan="2">Opeartions</td>
</tr>
<?php

$servername="localhost";
$username="root";
$password="";
$dbname="q2";
$con=mysqli_connect($servername,$username,$password,$dbname);
$query="SELECT*FROM show_record1";
$data1=mysqli_query($con,$query);
$data=mysqli_num_rows($data1);
echo $data;
if(isset($_POST['select']))
{

if($data!=0)
{
while($res=mysqli_fetch_assoc($data1))
{
echo"<tr>
<td>".$res['Studentname']."</td>
<td>".$res['Marks']."</td>
<td>".$res['Cnic']."</td>
<td>".$res['RollNumber']."</td>
<td>".$res['SubjectName']."</td>
<td>".$res['Class']."</td>
<td>".$res['Section']."</td>
</tr>";

}
}
}
?>
</table>

<?php
if(isset($_GET['delete']))
{

$servername="localhost";
$username="root";
$password="";
$dbname="q2";
$con=mysqli_connect($servername,$username,$password,$dbname);
$r=$_GET['sname'];

$sql="DELETE FROM show_record1 WHERE Studentname='$r'";

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

echo"Data has been deleted.";


}
else
{
echo"Data is not deleted.";
}
}
?>
<?php

$servername="localhost";
$username="root";
$password="";
$dbname="q2";
$con=mysqli_connect($servername,$username,$password,$dbname);
if(isset($_GET['update']))
{
$Studentname=$_GET['sname'];
$Marks=$_GET['mark'];
$Cnic=$_GET['cnic'];
$RollNumber=$_GET['rolno'];

$SubjectName=$_GET['subname'];
$Class=$_GET['clas'];
$Section=$_GET['sec'];
$sql="UPDATE show_record1 SET Marks='$Marks',Cnic='$Cnic', RollNumber='$RollNumber',
SubjectName='$SubjectName' ,Class='$Class' ,Section='$Section' WHERE
Studentname='$Studentname'";
if(mysqli_query($con,$sql))
{

echo"Data has been updated";

}
else{

echo"data is not updated";


}
}
?>
</body>
</html>

J-query programs:
Q1: Make a JQuery Function to show the Slide Toggle Effect on the Images.
<html>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script language="JavaScript">

var i=0,images=["CRWN-3W-2500K-B22-NT_GREY-1.jpg","Light-bulb-vector.jpg","bulb-electricity-energy-
glass-45227.jpeg"
,"lunnom-led-bulb-e-lumen__0607428_PE682943_S4.JPG","htpr.cnet.com.jpg","lightbulb-neon-light-
amped-co-trophy-incandescent_360_676x676.jpg",
"26_2049425i.jpg","index.jpg","A19-E26-socket-Transparent-Incandescent-blue-party-sign-lamp-light-
bulb-IMG_1506.jpg","glodepaerer.jpg","240_277.jpg"];
function myslide(x)
{

if(x=='next')
{

i++;
if(i==images.length)
{
i=images.length-1;
}
}
else
{

i--;
if(i<0)
{
i=0;
}
}
document.getElementById('2nd').src=images[i];

}
</script>
<script>
$(document).ready(function(){
$("#bttn1").click(function(){
$("#2nd").fadeOut();
$("#2nd").slideDown();
});
$("#bttn2").click(function(){
$("#2nd").fadeOut();
$("#2nd").slideDown();
});
});
</script>
<body>
<p id="1st">web programming</p>
<img id="2nd" src="E:\bulloff.JPG" width='150' height='150'>
<button type="button" id="bttn2" onclick="myslide('prev');">Back</button>
<button type="button" id="bttn1" onclick="myslide('next');">Next</button>
</body>
</html>

Q2: Make a JQuery Function when user click the button then Address of the Student is Show using alert
box and if user clicks on the Hide Button the address and all information can be hide.
<html>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>

$(document).ready(function(){
$("#bttn1").click(function(){
alert("The ADDRESS:"+"Green Town ");
});
$("#bttn2").click(function(){
alert("THE ADDRESS"+"");
});
});
</script>
<body>
<input type="button" id="bttn1" value="Show"/>
<input type="button" id="bttn2" value="Hide"/>
</body>
</html>

Q3: Create a JQuery Function to access the form field value using built in functions.
<html>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$(document).ready(function(){
$("#bttn1").click(function(){
alert("The value is:"+$("#txt1").val());
});
});
</script>
<body>
<form>
Enter the value:<input type="Text" id="txt1"/>
<input type="button" id="bttn1" value="Show"/>
</form>
</body>
</html>

Vous aimerez peut-être aussi