Professional Documents
Culture Documents
<?php
/* First method to create an associate array. */
$student_one = array("Maths"=>95, "Physics"=>90,
"Chemistry"=>96, "English"=>93,
"Computer"=>98);
<?php
$n1=35;
$n2=043;
$n3=0x23;
$str="going BACK he SAW THIS";
$str1="mumbai TO goa";
//function "chr()"
echo "The equivalent character for ASCII 35 in decimal is ";
echo chr($n1). "\n";
echo "<br>";
//function "ord()"
echo ord("twinkle");//ASCII value of 't';
echo "<br>";
//function "strtolower()"
$resstr=strtolower($str);
echo $resstr;
echo "<br>";
//function "strtoupper()"
$resstr1=strtoupper($str1);
echo $resstr1;
echo "<br>";
//function "strlen()"
echo strlen("hello");
echo "<br>";
//function "strrev()"
echo strrev($str);
?>
Q3.Write a PHP script to send the data from one page to another page.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="Q3a.php" method="post">
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><br>
<input type="submit" name="submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
welcome
<?php
echo $_POST["fname"];
?>
<?php
echo $_POST["lname"];
?>
</body>
</html>
Q5. Write a PHP script to perform CRUD operation.
Q1(home)
<!DOCTYPE html>
<html>
<head>
<title>Landing Page</title>
</head>
<body>
<h1>Select any option</h1>
<button><a href="q1insert.php">INSERT Record in Table</a></button>
<button><a href="q1update.php">UPDATE Record in Table</a></button>
<button><a href="q1delete.php">DELETE Record from Table</a></button>
<button><a href="q1display.php">DISPLAY Table Records</a></button>
</body>
</html>
Q1(delete)
<?php
if(isset($_GET['d'])){
$server="localhost";
$user="root";
$pwd="";
$dbase="aadil";
$conn=new mysqli($server,$user,$pwd,$dbase);
if(!$conn){
echo "No Connection";
}
$number=$_GET['t1'];
if($conn->query($query)===TRUE){
echo "Record deleted successfully";
}else{
echo "Error Deleting record: ";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>deletion</title>
</head>
<body>
<form>
Enter Number: <input type="text" name="t1"> <br> <br>
<input type="submit" name="d" value="deletion"> <br> <br> <br>
<button><a href="q1.php">Go to Main Page</a></button>
</form>
</body>
</html>
Q1(display)
<?php
$server="localhost";
$user="root";
$pwd="";
$dbase="aadil";
$conn=new mysqli($server,$user,$pwd,$dbase);
if(!$conn){
echo "Not Connected";
}
}else{
echo "0 result";
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<button><a href="q1.php">Go to Main Page</a></button>
</body>
</html>
Q1(insert)
<?php
if(isset($_GET['s'])){
$server="localhost";
$user="root";
$pwd="";
$dbase="aadil";
$conn=new mysqli($server,$user,$pwd,$dbase);
if($conn){
echo "connected";
}else{
echo "not connected";
}
$number=$_GET['t1'];
$name=$_GET['t2'];
$contect=$_GET['t3'];
$post=$_GET['t4'];
$salary=$_GET['t5'];
$res=mysqli_query($conn,$query);
if(!$res){
echo "Record not inserted";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form>
Enter Number: <input type="text" name="t1"> <br> <br>
Enter Name: <input type="text" name="t2"> <br> <br>
Enter Contect: <input type="text" name="t3"> <br> <br>
Enter Post: <input type="text" name="t4"> <br> <br>
Enter Salary: <input type="number" name="t5"> <br> <br>
<input type="submit" name="s" value="Register"> <br> <br> <br>
<button><a href="q1.php">Go to Main Page</a></button>
</form>
</body>
</html>
Q1(insert)
<?php
if(isset($_GET['s'])){
$server="localhost";
$user="root";
$pwd="";
$dbase="aadil";
$conn=new mysqli($server,$user,$pwd,$dbase);
if($conn){
echo "connected";
}else{
echo "not connected";
}
$number=$_GET['t1'];
$name=$_GET['t2'];
$contect=$_GET['t3'];
$post=$_GET['t4'];
$salary=$_GET['t5'];
$res=mysqli_query($conn,$query);
if(!$res){
echo "Record not inserted";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form>
Enter Number: <input type="text" name="t1"> <br> <br>
Enter Name: <input type="text" name="t2"> <br> <br>
Enter Contect: <input type="text" name="t3"> <br> <br>
Enter Post: <input type="text" name="t4"> <br> <br>
Enter Salary: <input type="number" name="t5"> <br> <br>
<input type="submit" name="s" value="Register"> <br> <br> <br>
<button><a href="q1.php">Go to Main Page</a></button>
</form>
</body>
</html>