sumber: https://www.niagahoster.co.id/blog/cara-membuat-website-php/
To create a website, you need to master basic HTML and CSS to build a good structure and an attractive appearance. Well, how to create a website with PHP from scratch can be done with the following steps:
- Prepare the software used
- Create an index.php file
- Create a style.css file
- Create a home.php file
- Create a file about.php
- Create a contact.php file
- Try the website in the browser
Step 1: Preparation
Here are the various tools you need to prepare before creating a PHP website:
PHP Editor – Used to create website files and write code. This time we are using Sublime Text.
Web Browser – Useful for checking the appearance of the website. We are using Google Chrome in this tutorial.
Web Server – As a place to store website folders. Here we use XAMPP and then create a folder called websitephp in c:\xampp\htdocs.
Step 2: Creating the index.php File
Open Sublime Text, then click File > New File. Then, enter the source code in the following example or your own source code as desired:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!DOCTYPE html> <html lang= "en" > <head> <title>Membuat Website dengan PHP | Niagahoster</title> <meta charset= "UTF-8" > <meta name= "description" contents= "Niagahoster" > <link rel= "stylesheet" href= "style.css" type= "text/css" > </head> <body> <header> <h1 class = "title" >Niagahoster</h1> <h3 class = "desc" >Membuat Website dengan PHP dari Awal</h3> <nav id= "navigation" > <ul> <li><a href= "index.php?page=home" >Home</a></li> <li><a href= "index.php?page=about" >About</a></li> <li><a href= "index.php?page=contact" >Contact</a></li> </ul> </nav> </header> <div id= "contents" > <?php if (isset( $_GET [ 'page' ])){ $page = $_GET [ 'page' ]; switch ( $page ) { case 'home' : include "home.php" ; break ; case 'about' : include "about.php" ; break ; case 'contact' : include "contact.php" ; break ; } } else { include "home.php" ; } ?> </div> <footer> & copy Copyright Niagahoster 2021 | Web Hosting Terbaik Indonesia </footer> </body> </html> |
If so, save the file with the name index.php in the websitephp folder.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
header h 1 .title, header h 3 .desc{ text-align : center ; } body { width : 70% ; margin : auto ; } a:link { color : gray ; } a:visited { color : green ; } a:hover { color : rebeccapurple; } a:active { color : teal ; } #navigation { } p { font-size : 110% ; color : black ; } #contents { float : center ; } ul { list-style-type : none ; margin : 0 ; padding : 0 ; overflow : hidden ; background-color : black ; font-family : sans-serif ; } li { float : left ; } li a { display : block ; color : white ; text-align : center ; padding : 14px 16px ; text-decoration : none ; } li a:hover { background-color : #fff ; } footer { text-align : center ; } |
Save with the name style.css.
1
2
3
4
|
<div class = "page" > <h2>Website Hebat Berawal dari Unlimited Hosting</h2> <p>Kami berikan penawaran terbaik unlimited web hosting. Fitur terlengkap, harga terjangkau, dan dukungan teknis 24/7 telah tersedia untuk Anda.</p> </div> |
Next, save it with the name home.php.
1
2
3
4
|
<div class = "page" > <h2>Tentang Niagahoster</h2> <p>Telah dipercaya lebih dari 500.000 klien yang terdaftar dari seluruh Indonesia, Niagahoster selalu berkomitmen menyajikan teknologi terbaik untuk kesuksesan online Anda. Bergabunglah dan temukan kemudahan menciptakan website impian Anda bersama Niagahoster!</p> </div> |
Save the file with the name about.php.
1
2
3
4
5
6
7
8
9
10
11
12
|
<div class = "page" > <h2>Hubungi Kami</h2> <p>Telp: 0274-2885822 <br>WA: 0895395186038 <br>Senin - Minggu 24 Jam Non Stop</p> <p>Jl. Palagan Tentara Pelajar No 81 Jongkang, Sariharjo, Ngaglik, Sleman Daerah Istimewa Yogyakarta 55581</p> </div> |
If so, save the file with the name contact.php.
Komentar Terbaru