PHP Nidhinandha
PHP Nidhinandha
PHP Nidhinandha
0
1. Write a PHP script to sort the given user defined array in either ascending or descending
order according to user choice.
Ans:-
<!DOCTYPE html>
<html lang="en">
<?php
$arr = ""; if
(isset($_POST['myarray'])) {
$arr = $_POST['myarray'];}?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>journal</title>
</head><body>
<form action="journal.php" method="post">
<table>
<tr><td class="t"> Enter
Your array :
</td><td>
<input type="text" name="myarray" id="myarray">
</td><td>Example : 1 2 33 44</td>
</tr><tr>
<td colspan="3" align="center"><button class="btn">Submit</button></td> </tr> </table>
<h3><?php echo "your array is $arr" ?></h3>
<table border="2">
<tr> <td>Ascending order
<td>
<td> <?php
if (isset($_POST["myarray"])) {
$str = $_POST["myarray"]; $arr
= explode(" ", $str); sort($arr);
foreach ($arr as $key => $value)
{ echo $value . " ";} echo
"<br>";}
?></td>
</tr><tr>
<td>Descending order
<td>
<td> <?php
if (isset($_POST["myarray"])) { $str
= $_POST["myarray"]; $arr
= explode(" ", $str); rsort($arr);
foreach ($arr as $key => $value)
1
{
2
echo $value . " ";} echo "<br>";}
?></td></tr>
</table></form>
</body></html>
OUTPUT:=
3
2.Create a registration form for patient with minimum 12 fields including file upload facility for reports
of the patients. Do necessary validations on all the fields. (Design Only).
ANS:-
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>journal
Q2</title>
</head><body>
<form action="journal2.php" method="post">
<h1>Patient Details form</h1>
<table border="2"><tr><td >
Patient Name :</td><td>
<input class="idata" type="text" name="pName" id="pName"> <p name="p" class="vld"></p></td>
<td class="hd">Patient Gender :</td><td>
<label for="male">
<input class="idata" type="radio" name="gender" id="male"> Male</label> <label for="female">
<input class="idata" type="radio" name="gender"
id="female"> Female</label><p name="p" class="vld"></p>
</td></tr><tr>
<td class="hd">
Blood Group : </td><td>
<input class="idata" type="text" name="bg" id="bg">
<p name="p" class="vld"></p></td>
<td class="hd">Date of Birth :</td><td>
<input class="idata" type="date" name="dob" id="dob">
<p name="p" class="vld"></p></td>
</tr><tr><td class="hd">Patient Address :</td><td>
<textarea class="idata" name="pAdd" id="pAdd" cols="25" rows="5">
</textarea> <p name="p" class="vld"></p></td><td
class="hd">Patient Contect :</td><td> <input class="idata"
type="number" name="pCon" id="pCon"> <p name="p"
class="vld"></p></td></tr><tr>
<td class="hd">Patient Email :</td><td>
<input class="idata" type="email" name="pEm" id="pEm">
<pname="p" class="vld"></p></td><td class="hd">
Patient Disease :</td><td><input class="idata" type="text" name="pDis" id="pDis">
<p name="p"class="vld"></p>
</td></tr><tr><td class="hd">
Doctor Name :</td><td>
<input class="idata" type="text" name="dName" id="dName">
<p name="p"class="vld"></p></td>
<td class="hd">Docter Contect :</td><td>
<input class="idata" type="number" name="dCon" id="dCon"> <p name="p"
class="vld"></p></td></tr><tr></tr><tr><td class="hd">Appoiment Date :</td><td>
4
<input class="idata" type="date" name="aDate" id="aDate"> <p name="p"class="vld"></p></td><td class="hd">
Report :</td><td><input class="idata" type="file" name="file" id="file"> <p name="p"class="vld"></p>
</td></tr></table><div style="text-align: center;margin-top: 20px;">
<input class="btn" type="submit" value="SUBMIT">
<input class="btn" type="reset" value="RESET"></div></form>
<div class="srh"><input type="text" > <button class="btn">Search</button></div> <div>
<table class="dtbl" border="2"><tr><th>ID</th><th>pName</th>
<th>pGender</th><th>B-Group</th><th>DOB</th><th>pAddress</th>
<th>pContect</th><th>pEmail</th> <th>pDisease</th><th>dr.Name</th><th>
dr.Contect</th><th>Date</th><th>report</th>
<th>Delete</th><th>Edit</th></tr><tr>
<td>1</td><td>Aditya</td><td>Male</td><td>O+
</td><td>15/12/2002</td>
<td>surat</td><td>9765274382</td>
<td>adi@gmail.com</td><td>dengue</td><td>vivek</td>
<td>8487283749</td><td>7/8/2022</td><td></td>
<td><Button class="btn red" >Delete</Button></td>
<td><Button class="btn blue">Edit</Button></td>
</tr></table></div>
</body>
</html>
5
6
3. Perform CRUD Opration for the patient . also provide search patient
facility. Ans:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>journal Q2</title>
</head><body>
<?php $pname = "";
$bgroup = "";$pgender = "";$dob = "";
$paddress = "";$pcon = "";$pemail = "";
$pdis = "";$drname = "";$drcon = "";
$apdate = "";$report = "";
$uid = "";if (isset($_POST['submit'])) {
$pname = $_POST['pname'];
$bgroup = $_POST['bgroup'];
$pgender = ""; if (!empty($_POST['pgender'])) {
$pgender = $_POST['pgender'];
} $dob = $_POST['dob'];
$paddress = $_POST['paddress'];
$pcon = $_POST['pcon'];
$pemail = $_POST['pemail'];
$pdis = $_POST['pdis'];
$drname = $_POST['drname'];
$drcon = $_POST['drcon'];
$apdate = $_POST['apdate'];
$report = $_POST['report'];
} if (isset($_GET['uid'])) {
$str = "SELECT * FROM `hospital` WHERE id=" . $_GET['uid'];
$con = mysqli_connect("localhost", "root", "","demo");
$r = $con->query($str);
$row = $r->fetch_assoc();
$pname = $row["pname"]; $pgender = $row["pgender"];
$bgroup = $row["bgroup"]; $dob = $row["dob"];
$paddress = $row["paddress"]; $pcon = $row["pcon"];
$pemail = $row["pemail"];
$pdis = $row["pdis"]; $drname = $row["drname"];
$drcon = $row["drcon"];
$apdate = $row["apdate"]; $report = $row["report"] == "" ? $row['report'] : $row['report']; } if
(isset($_POST['reset'])) { $pname = ""; $bgroup = "";
$pgender = ""; $dob = "";
$paddress = "";
$pcon = ""; $pemail = "";
$pdis = "";
$drname = ""; $drcon = "";
7
$apdate = ""; $report =
""; } if
(isset($_POST['update'])) {
$uid = $_POST['uid'];
$pname = $_POST["pname"];
$pgender = $_POST["pgender"];
$bgroup = $_POST["bgroup"];
$dob = $_POST["dob"];
$paddress = $_POST["paddress"];
$pcon = $_POST["pcon"];
$pemail = $_POST["pemail"];
$pdis = $_POST["pdis"];
$drname = $_POST["drname"];
$drcon = $_POST["drcon"];
$apdate = $_POST["apdate"];
$con = mysqli_connect("localhost", "root", "","demo");
$str = "SELECT * FROM `hospital` WHERE id=" . $uid; $r = $con->query($str);
$row = $r->fetch_assoc();
$report = isset($_POST['report']) ? $_POST['report'] : $row['report']; $str = "UPDATE
`hospital` SET
`pname`='$pname',`pgender`='$pgender',`bgroup`='$bgroup',`dob`='$dob',`paddress`='$paddress',`pcon`='$p
con',`pemail`='$pemail',`pdis`='$pdis',`drname`='$drname',`drcon`='$drcon',`apdate`='$apdate',`report`= '$report'
WHERE id=" . $uid;
echo $str; if (
$pname != "" and
$bgroup != "" and $pgender != "" and
$dob != "" and $paddress != "" and
$pcon != "" and $pemail != "" and
$pdis != "" and $drname != "" and
$drcon != "" and $apdate != "" and
$report != "") {
$res = $con->query($str); if
($res) { header("Location:journal2.php");
}}}?>
<form action="jouranl2.php" method="POST">
<h1 >Patient Details Form</h1>
<input type="hidden" name="uid" value="<?php if (isset($_GET['uid']) and $_GET['uid'] != "")
{echo $_GET['uid'];
} ?>">
<table border="2"> <tr><td
class="hd"> Patient Name :
</td><td>
<input class="idata" type="text" name="pname" value="<?php echo $pname ?>" id="pName"><p
name="p" class="vld">
<?php if (isset($_POST['pname']) and $_POST['pname'] == "") { echo"<br>plesae enter patient name";
} ?></p></td>
8
<td class="hd">
Patient Gender
:</td>
<td><label for="male">
<input class="idata" type="radio" name="pgender" <?php if ($pgender ==
"male") {echo "checked"; }
?> value="male" id="male">
Male</label>
<label for="female"><input class="idata" type="radio" name="pgender" <?php if ($pgender ==
"female") {echo "checked"; }
?> value="female"
id="female"> Female</label>
<p name="p" class="vld"><?php if (isset($_POST['submit']) and empty($_POST['pgender'])) { echo "<br>plesae
Select Patient Gender";} ?></p>
</td></tr><tr>
<td class="hd">
Blood Group : </td>
<td><input class="idata" type="text" name="bgroup" value="<?php echo $bgroup ?>" id="bg"><p
name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['bgroup'])) { echo "<br>plesae
Enter Blood Group";
} ?></p></td><td class="hd">
Date of Birth :</td><td>
<input class="idata" type="date" name="dob" value="<?php echo $dob ?>" id="dob"><p name="p"
class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['dob'])) { echo "<br>plesae
Select Patient Blood Group";
} ?></p></td></tr><tr>
<td class="hd">Patient Address :</td><td>
<textarea class="idata" name="paddress" id="paddress" cols="25" rows="5"><?php echo $paddress
?></textarea><p name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['paddress'])) { echo "<br>plesae
Select Patient Address";
} ?></p></td><td class="hd">
Patient Contect :</td><td><input class="idata" type="number" name="pcon" value="<?php echo $pcon ?>"
id="pCon"><p name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['pcon'])) { echo "<br>plesae
Enter Patient Contect";} ?></p></td></tr><tr><td class="hd">
Patient Email :</td><td>
<input value="<?php echo $pemail ?>" class="idata" type="email" name="pemail" id="pEm"><p
name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['pemail'])) { echo "<br>plesae
Enter Patient Email";} ?>
</p></td><td class="hd">
Patient Disease
:</td><td>
9
<input class="idata" type="text" value="<?php echo $pdis ?>" name="pdis" id="pDis"><p name="p"
class="vld">
1
<?php if (isset($_POST['submit']) and empty($_POST['pdis'])) { echo "<br>plesae
Enter Patient Disease";} ?></p></td></tr>
<tr><td class="hd">Doctor Name :</td><td>
<input class="idata" type="text" value="<?php echo $drname ?>" name="drname" id="dName"><p
name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['drname'])) { echo "<br>plesae
Enter Doctor name";
} ?></p></td><td class="hd">
Docter Contect :</td><td>
<input class="idata" type="number" value="<?php echo $drcon ?>" name="drcon" id="dCon"><p
name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['drcon'])) { echo "<br>plesae
Enter Doctor Contect";} ?>
</p></td></tr><tr>
<td class="hd">Appoiment Date :</td><td>
<input class="idata" type="date" value="<?php echo $apdate ?>" name="apdate" id="aDate"><p
name="p" class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['apdate'])) { echo "<br>plesae
Enter Appoiment Date";} ?></p></td>
<td class="hd">Report :</td><td>
<input class="idata" type="file" value="<?php echo $report ?>" name="report" id="file"><p name="p"
class="vld">
<?php if (isset($_POST['submit']) and empty($_POST['report'])) { echo "<br>plesae
Select File";} ?></p></td></tr></table>
<div style="text-align: center;margin-top: 20px;">
<input class="btn" type="submit" name="submit" value="SUBMIT"> <input class="btn"
type="submit" name="reset" value="RESET"> <?php if (isset($_GET['uid'])) {?><input class="btn"
type="submit" name="update" value="UPDATE"> <?php
}?></div></form><?php
$con = mysqli_connect("localhost","root","","demo"); if
(isset($_POST['submit'])) { $pname =
$_POST['pname'];
$bgroup = $_POST['bgroup'];
$pgender = ""; if (!
empty($_POST['pgender'])) {
$pgender = $_POST['pgender'];}
$dob = $_POST['dob'];
$paddress = $_POST['paddress'];
$pcon = $_POST['pcon'];
$pemail = $_POST['pemail'];
$pdis = $_POST['pdis'];
$drname = $_POST['drname'];
$drcon = $_POST['drcon'];
$apdate = $_POST['apdate'];
$report = $_POST['report'];if (
$pname != "" and $bgroup != "" and
1
$pgender != "" and $dob != "" and
$paddress != "" and $pcon != "" and
$pemail != "" and $pdis != "" and
$drname != "" an d$drcon != "" and
$apdate != "" and $report != "" ) {
$q = "INSERT INTO `hospital` ( `pname`, `pgender`, `bgroup`, `dob`, `paddress`, `pcon`, `pemail`, `pdis`,
`drname`, `drcon`, `apdate`, `report`) VALUES ( '$pname', '$pgender', '$bgroup', '$dob', '$paddress', '$pcon',
'$pemail', '$pdis',
'$drname', '$drcon', '$apdate', '$report')";
$con->query($q); $pname = "";
$bgroup = ""; $pgender = "";
$dob = ""; $paddress = "";
$pcon = ""; $pemail = "";
$pdis = ""; $drname = "";
$drcon = ""; $apdate = "";
$report = ""; }}?>
<form action="journal2.php" method="post">
<div class="srh">
<input type="text" name="searchText">
<input type="submit" value="Search" name="search"> </div>
</form><div>
<table class="dtbl">
<tr><th>ID</th> <th>pName</th>
<th>pGender</th> <th>B-Group</th>
<th>DOB</th> <th>pAddress</th>
<th>pContect</th> <th>pEmail</th>
<th>pDisease</th> <th>dr.Name</th>
<th>dr.Contect</th> <th>Date</th>
<th>report</th> <th>Delete</th>
<th>Edit</th> </tr>
<?php
if (isset($_POST['search'])) {
$query = "SELECT * FROM `hospital`";
$r = $con->query($query); if ($r->num_rows > 0) {
while ($row = $r->fetch_assoc()) {?> <tr><td><?php
echo $row["id"]; ?></td>
<td><?php echo $row["pname"]; ?></td>
<td><?php echo $row["pgender"]; ?></td>jo
<td><?php echo $row["bgroup"]; ?></td>
<td><?php echo $row["dob"]; ?></td>
<td><?php echo $row["paddress"]; ?></td>
<td><?php echo $row["pcon"]; ?></td>
<td><?php echo $row["pemail"]; ?></td>
<td><?php echo $row["pdis"]; ?></td>
<td><?php echo $row["drname"]; ?></td>
<td><?php echo $row["drcon"]; ?></td>
1
<td><?php echo $row["apdate"]; ?></td>
<td><?php echo $row["report"]; ?></td>
<td><button class="btn red" onclick="location.href =
'delete.php?id=<?php echo $row['id']; ?>'">Delete</button></td>
<td><button class="btn blue" onclick="location.href =
'index.php?uid=<?php echo $row['id']; ?>'">Edit</button></td> </tr>
<?php}}} else {
$query = "SELECT * FROM `hospital`";
$r = $con->query($query); if ($r>num_rows
> 0) { while ($row = $r>fetch_assoc()) {?>
<tr><td><?php echo
$row["id"]; ?></td>
<td><?php echo $row["pname"]; ?></td>
<td><?php echo $row["pgender"]; ?></td>
<td><?php echo $row["bgroup"]; ?></td>
<td><?php echo $row["dob"]; ?></td>
<td><?php echo $row["paddress"]; ?></td>
<td><?php echo $row["pcon"]; ?></td>
<td><?php echo $row["pemail"]; ?></td>
<td><?php echo $row["pdis"]; ?></td>
<td><?php echo $row["drname"]; ?></td>
<td><?php echo $row["drcon"]; ?></td>
<td><?php echo $row["apdate"]; ?></td>
<td><?php echo $row["report"]; ?></td>
<td><button class="btn red" onclick="location.href =
'delete.php?id=<?php echo $row['id']; ?>'">Delete</button></td>
<td><button class="btn blue" onclick="location.href =
'index.php?uid=<?php echo $row['id']; ?>'">Edit</button></td> </tr>
</table>
</div>
<?php if(isset($_GET['id'])){ $con = mysqli_connect("localhost","root","","demo"); $str = "DELETE FROM `hospital`
WHERE id=".$_GET['id']; $res = $con->query($str); if ($res) { header("Location:javascript:history.go(-1)"); } else{ echo
"Failed to Insertion.."; } } ?>
</body>
</html>
1
Output:=
1
4. Create a sign in form for patient. Upon successful sign in patient can give feedback about hospital
using feedback form. Create feedback form. Manage session and cookies between the logs in and log out
process. ANS:
<?php
if (isset($_GET['id'])) { $user_id
= $_GET['id'];
$sql = "SELECT * FROM `users` WHERE `id`='$user_id'";
$result = $conn->query($sql); if
($result->num_rows > 0)
while ($row = $result->fetch_assoc()) {
$email = $row['email'];
$password = $row['password'];
$id = $row['id']; } }?>
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css"> <script> function
validateForm() { let x = document.forms["myForm"]
["email"].value; let y =
document.forms["myForm"]["password"].value; if (x ==
"" && y=="") {
alert("Please enter email and password"); return
false; }else if(x==""){
alert("Please enter email");
return false;
}else if(y==""){ alert("Please
enter password"); return false;
}else{
if(x==$email && y==$password){
return true; }else{
alert("Please check your email and password");
return false; } } } var loadFile = function(event)
{
var image = document.getElementById('output');
image.src = URL.createObjectURL(event.target.files[0]);
}; </script></head><body>
<div class="container">
<div class="title">Sign in</div>
<div class="content">
<form method="POST" name="myForm" onsubmit="return validateForm()" action="feedback.php">
<div class="user-details">
<div class="input-box">
<span class="details">Email</span>
<input type="text" name="email" placeholder="Enter your email" required>
</div> <div class="input-box">
1
<span class="details">Password</span>
<input type="text" name="password" placeholder="Enter your password" required>
</div> </div> <div class="button">
<input type="submit" value="Sign in" name="submit">
</div> </form> </div>
<div><a href="patient_registration.php">Registor</a>
</div></div></body> </html>
Feedback.php:-
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> <body>
<div class="form_box shadow">
<form method="post" action="practice.php">
<div class="heading">
Feedback Form </div> <br/>
<p>What do you think about the quality of our blog?</p> <div>
<div class="pic"> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Emoji_u1f610.svg/
800px-Emoji_u1f610.svg.png" alt="" width="60"> <br/>
<input type="radio" name="quality" value="0"> Bad
</div> <div class="pic">
<img src="https://www.pinclipart.com/picdir/middle/228-2283979_emoji-wikipedia-clipart.png" alt="" width="60">
<br/>
<input type="radio" name="quality" value="1"> Okay </div>
<div class="pic"> <img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Twemoji_1f600.svg/220px-
Twemoji_1f600.svg.png" alt="" width="60"> <br/>
<input type="radio" name="quality" value="2"> Good
</div> </div>
<p>Do you have any suggestion for us? </p>
<textarea name=" suggestion" rows="8" cols="40"></textarea>
<input type="submit" name="submit" value="Submit Form"> </form>
</div></body></html>
1
1
5. Wirte a python program to perform count visitors of page and cell it using php. ANS:
<?php
$con = mysqli_connect("localhost", "root", "", "yagnesh"); $query = "SELECT
* FROM visit";
$res = $con->query($query);
$Cnt = mysqli_fetch_array($res);
$output = $Cnt["visit"];
$cmd = escapeshellcmd('python yagnesh.py ' . $output);
$out = exec($cmd); if
($out != "") {
$query = "UPDATE `visit` SET visit=" . $out;
$res = $con->query($query);
$output = $out;
}
mysqli_close($con);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>question 5</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Totel visitor are = <?php echo $output; ?></h1>
</body>
</html> output:=
1
6. Write a php script to create photo album application and call it using python. - Create album -
upload Photo In album - display album in gallery
ANS:-
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Question5</title>
<link rel="stylesheet" href="home.css">
</head><body>
<?php $data= exec(escapeshellcmd("python photo.py Aditya”)); $data = explode(" ",$data);
$con = mysqli_connect($data[0], $data[1], $data[2], $data[3]); $albumName = ""; if
(isset($_POST["btn"])) {
$albumName = $_POST["albumname"]; if
($albumName != "") {
$str = "INSERT INTO `album`(name) VALUE ('$albumName') "; $con-
>query($str);$albumName = "";}}?>
<form action="home.php" method="post">
<div class="header">
<h3>Album Name :</h3>
<input type="text" name="albumname" id="albumname" value="<?php echo $albumName; ?>"> <button
type="submit" name="btn" class="btn">Add</button><br><br>
</div><div><?php
$str = "SELECT * FROM album";
$res = $con->query($str);
$data = mysqli_fetch_all($res);
// print_r($data); for ($i = 0; $i <
count($data); $i++) { ?>
<div class="imageback">
<a href="album.php?album=<?php echo $data[$i][0]; ?>" style="font-size: 0em" name="data"> <img
class="image" src="
<?php $str = "select * from image where album=" .
$data[$i][0];
$res = $con->query($str);
$img = mysqli_fetch_row($res)[1] ?? ""; echo $img;?>
" alt="no image" width="100" srcset=""> <p class="txt"><?php print_r($data[$i][1])
?></p>
</a></div><?php } ?>
</div>
</form>
</body>
</html>
Album.php:-
<!DOCTYPE html>
1
<html lang="en">
<?php if (!isset($_GET['album'])) { header("Location:home.php");
} if (isset($_POST['back'])) { header("Location:home.php");
}
$id = $_GET['album'];
$data= exec(escapeshellcmd("python yagnesh.py yagnesh")); $data = explode(" ",$data);
$con = mysqli_connect($data[0], $data[1], $data[2], $data[3]); if
(isset($_FILES['pic']) and $_FILES['pic']['name'] != "") { echo
$_FILES['pic']['tmp_name']; $img_name =
$_FILES['pic']['name'];
$img_path = $_FILES['pic']['tmp_name']; $folder =
"img/" . $img_name; move_uploaded_file($img_path,
"img/" . $img_name);
$query = "insert into image(pic,album) values('$folder',$id) "; $run = mysqli_query($con,
$query); header("Location:album.php?album=$id"); }
$str = "SELECT * FROM image WHERE album=" . $_GET['album']; // echo $str;
$res = $con->query($str);
$data = mysqli_fetch_all($res); ?>
<head> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet"
href="album.css">
<title>myAlbum</title> </head> <body>
<form action="" method="post" enctype="multipart/form-data" id="myform"> <div class="header">
<button class="btn" type="submit" name="back"> < </button>
<p class="name"><?php
$str = "SELECT * FROM album where id=$id";
$res = $con->query($str);
$name = mysqli_fetch_row($res)[1]; echo
$name; ?></p> </div>
<?php if (count($data) != 0) {
?> <?php for ($i = 0; $i <
count($data); $i++) { ?> <a
href="image.php?id=<?php echo
$data[$i][0];
?>"> <img class="img" src="<?php echo $data[$i][1]; ?>" alt="image not found" srcset=""
height="200">
</a> <?php
}?>
<?php
} else { ?>
<div class="no">no image</div> <?php } ?>
<label for="pic" class="add">+
<input type="file" name="pic" id="pic" onchange="form.submit();" hidden> </label>
</form>
</body>
1
</html>
Image.php:-
<!DOCTYPE html>
<html lang="en"> <?php
if (!isset($_GET['id'])) { header("Location:home.php");
} if ($_GET['id'] == "") {
echo "<script>history.back()</script>";
} $id = $_GET['id'];
$data= exec(escapeshellcmd("python yagnesh.py yagnesh")); $data = explode(" ",$data);
$con = mysqli_connect($data[0], $data[1], $data[2], $data[3]); $str = "SELECT *
FROM image WHERE id=" . $id;
// echo $str; $res = $con->query($str); $data =
mysqli_fetch_row($res); if (isset($_POST['back'])) {
header("Location:album.php?album=" .
$data[2]);
} if (count($data) <= 1) { header("Location:home.php");
} if (isset($_POST['p'])) {
$album = $data[2];
$str = "SELECT * FROM image WHERE album=" . $album;
// echo $str;
$res = $con->query($str);
$dataArray = mysqli_fetch_all($res);
// print_r($dataArray);
$num = array_search($data, $dataArray); $img
= $dataArray[$num + 1][0];
header("Location:image.php?id=" . $img);
} if (isset($_POST['b'])) {
$album = $data[2];
$str = "SELECT * FROM image WHERE album=" . $album;
// echo $str;
$res = $con->query($str);
$dataArray = mysqli_fetch_all($res);
// print_r($dataArray);
$num = array_search($data, $dataArray); $img
= $dataArray[$num - 1][0]; header("Location:image.php?id="
. $img); } ?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>image</title>
<link rel="stylesheet" href="image.css">
</head>
<body>
<form action="" method="post">
<div class="header">
1
<button class="btn" type="submit" name="back">
<< </button> <p class="name"><?php echo
$data[1]; ?></p> </div>
<div class="img">
<img class="image" src="<?php echo
$data[1];
?>" alt="" srcset="">
</div> <div class="bottom">
<button class="bp" name="b" type="submit">↩</button> <button class="bp"
name="p" type="submit">↪</button>
</div> </form>
</body>
</html>
Output: