How to display pdf file, dynamic link and autorefresh time in to one php file
What Will I Learn?
- You will learn How to display pdf file
- You will learn How to create dynamic link
- You will learn How to created autorefresh time
- You will learn How to combine pdf files, dynamic links and autorefresh time in one php file
Requirements
Write here a bullet list of the requirements for the user in order to follow this tutorial.
- You have basic about HTML
- You have basic about PHP
- To practice this tutorial need a text editor file (Notepad ++), browser (Google Chrome) and server (localhost, XAMPP).
Difficulty
Either choose between the following options:
- Basic
Tutorial Contents
In this tutorial we will create how to display pdf file, how to create dynamic link, and autorefresh time in one php file, using html tag.
- How to display pdf file
- First open your server localhost (XAMP)
- Next,Open your text editor ( notepad ++)
- After that Create new file and save as html extention, like pdf.html and do not forget to prepare a pdf file into the html folder earlier so that when the invocation of the file in input it can appear
- LastlyCreate html element as usual.
<html>
<head>
<title>How to display pdf file</title>
</head>
<embed width="600" height="450" src="nilai_siswa.pdf" type="application/pdf"></embed>
<body>
</body>
</html>
- Output
- Explanation
<embed width="600" height="450" src="nilai_siswa.pdf" type="application/pdf"></embed>
<embed></embed>
- embed is a html tag, which functions to display external files, such as files, videos, mp3, pdf, and multimedia files on web pages, and at this time we just focus on how to display pdf files.
width="600"
- width="600"width is a width attribute of a pdf file whose width is 600 in size.
height="450"
- height="450" is a high attribute of the size of the value 450 in the pdf file.
src="nilai_siswa.pdf"
- src="nilai_siswa.pdf
function to call the pdf file you want to display, examples such as "nilai_siswa" is the name of the file to be displayed.
type="application/pdf"
type="application/pdf"is a working header displaying pdf files on web pages.
How to create dynamic link
Next,Open your text editor ( notepad ++)
After that create a new file and save it as PHP extention, with index.php file name
Finally fill in the html and scrip php elements as below.
<!Doctype HTML>
<head>
<title>How to create dynamic link</title>
</head>
<body >
<a href='index.php'><input type="submit" value="LINK ONE HOME" ></a><br/>
<a href='index.php?p=contact'><input type="submit" value="LINK TWO CONTACT PAGE " ></a><br/>
<a href='index.php?p=profile'><input type="submit" value="LINK THREE PROFILE PAGE" ></a><br/><hr/>
<?php
error_reporting(0);
switch($_GET['p'])
{
default:
echo "<b> <center> welcome to homepage </center> </b>";
break;
case "contact";
echo "<center> <b> <p>CONTACT NAME PAGE</p> <p>NAME : DONGKRAK</p>
<p> RESIDENCE : NANGROE UTARA ACEH</p></b></center>";
break;
case "profile";
echo "<center> <b> <p>PROFILE PAGE</p><p>NAME : DONGKRAK</p>
<p> RESIDENCE : NANGROE UTARA ACEH</p><p> STATUS : STUDENDT CEUMATOK</p> </b></center>";
break;
}
?>
</body>
</html>
- Output LINK ONE HOME
- Output LINK TWO CONTACT PAGE
- Output LINK THREE PROFILE PAGE
- Explanation
The a href attribute on this file is used to link to another page, this time we use the a href attribute in a single page by using submit button to link link only, then control the switch case structure, which we include break, in order for the structure is to executing from the results you want to display. - How to created autorefresh time
- Next,Open your text editor ( notepad ++)
- After that create a new file and save it as PHP extention, with time.php file name
- Finally fill in the html and scrip php elements as below.
<html>
<head>
<title>How to created autorefresh time</title>
</head>
<body>
<?php
$tanggal= mktime(date("m"),date("d"),date("Y"));
echo "<center>Tanggal : <b> ".date("d-M-Y", $tanggal)."</b> </center> ";
date_default_timezone_set('Asia/Jakarta');
$jam=date("H:i:s");
echo "<center> Pukul : <b>". $jam." "."</b></center";
$a = date ("H");
if (($a>=6) && ($a<=11)){
echo "<b><center>, Selamat Pagi !!</b></center>";
}
else if(($a>11) && ($a<=12))
{
echo "<center>, Selamat Pagi !!</center>";}
else if (($a>12) && ($a<=18)){
echo "<center>, Selamat Sore !!</center>";}
else { echo ", <b><center> Selamat Malam </b></center>";}
?>
</body>
</html>
- Output
- Explanation
The mktime () (abbreviation: make time) function in PHP is also used to obtain a specified time format timestamp. The time format I use this time is the time format, date_default_timezone_set ('Asia / Jakarta'). then we use the decision structure if else, to execute from the result of time in want it. - How to combine pdf files, dynamic links and autorefresh time in one php file
- Lastly,Open your text editor ( notepad ++)
- After that create a new file and save it as PHP extention, with index.php file name
- Finally fill in the html and scrip php elements as below.
<html>
<head>
<title>combinasi</title>
</head>
<body>
<a href='index.php'><input type="submit" value="HOME" ></a><br/>
<a href='index.php?p=kontak'><input type="submit" value="HALAMAN KONTAK" ></a><br/>
<a href='index.php?p=profil'><input type="submit" value="HALAMAN PROFIL" ></a><br/><hr/>
<embed width="600" height="450" src="nilai_siswa.pdf" type="application/pdf"></embed>
<?php
$tanggal= mktime(date("m"),date("d"),date("Y"));
echo "<center>Tanggal : <b> ".date("d-M-Y", $tanggal)."</b> </center> ";
date_default_timezone_set('Asia/Jakarta');
$jam=date("H:i:s");
echo "<center> Pukul : <b>". $jam." "."</b></center";
$a = date ("H");
if (($a>=6) && ($a<=11)){
echo "<b><center>, Selamat Pagi !!</b></center>";
}
else if(($a>11) && ($a<=12))
{
echo "<center>, Selamat Pagi !!</center>";}
else if (($a>12) && ($a<=18)){
echo "<center>, Selamat Sore !!</center>";}
else { echo ", <b><center> Selamat Malam </b></center>";}
?>
</body>
</html>
- Output
- Explanation
to get a result like the above output then you can copy the combination script that has been shown above, good luck ..
Curriculum
- My first contribution
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Hey @sametceylan, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
@dongkrak, I like your contribution to open source project, so I upvote to support you.
Hey @dongkrak I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x