#2 Tutorial Pemrograman Web – Konsep Dasar PHP, HTML, MySQL, Javascript, CSS

Seperti yang telah saya jelaskan pada postingan sebelumnya, ada beberapa hal yang harus dipahami pada pemrograman web.

  1. Server-side scripting (PHP, Python, Pearl, Java, C++, etc)
  2. Client-side scripting (HTML, Javascript, CSS, etc)
  3. Database (Oracle, MySQL, etc)

Untuk server-side dan database scripting, umumnya, kita hanya perlu belajar salah satu bahasa saja. Contoh, dengan hanya memahami PHP dan MySQL, dan sedikit pemahaman tentang client-side scripting, kita sudah bisa membuat sebuah website yang cukup powerful.

Pada gambar di atas, client side adalah program yang betul – betul ada di sisi client, namun kita sebagai developer harus membuat kode untuk client tersebut. Walaupun kita membuat kode hanya di sisi server, namun serverlah yang akan memproses kode tersebut untuk dikirimkan ke client. Program di sisi server akan mengkonversi dirinya sendiri menjadi bahasa pemrograman client-side seperti HTML, tergantung dengan bagaimana kita membuatnya di sisi server. Jadi, user yang berada di dsisi client tidak akan bisa melihat script PHP kita sama sekali. Yang bisa mereka lihat hanyalah kode HTML, CSS, Javascript, dan kode pemrograman client lainnya. Untuk lebih jelasnya, mari kita lihat contoh program PHP di bawah ini, yang filenya saya namakan dengan index.php.

<?php
echo 'This is my beautiful website.';
?>

Ketika seorang user melakukan request ke halaman index.php, server tidak akan mengirimkan kode seperti di atas ke user tersebut. Server akan mengkonversi kode PHP di atas menjadi kode client-side. Pada contoh di atas, server akan mengkonversi kode tersebut menjadi kode HTML di bawah ini.

Seperti yang bisa kita lihat, client hanya bisa melihat kode HTML, bukan PHP. Mereka hanya melihat kode client-side seperti Javascript, CSS, dan HTML. Bagi yang penasaran bagaimana cara untuk menampilkan raw code seperti di atas, klik kanan pada halaman browser Anda, kemudian klik inspect.

Sekarang mari kita pelajari sedikit lebih dalam mengenai kolaborasi Server, Client, dan Database Script. Mari kita buat kode PHP seperti di bawah ini, kita namakan dengan simpleweb.php

<!DOCTYPE html>
<html>
<head>
<style>
    table {
        width: 100%;
        border-collapse: collapse;
    }
    
    table, td, th {
        border: 1px solid black;
        padding: 5px;
    }
    
    th {text-align: left;}
</style>
<script>
  alert('Hey, JS is working here');
</script>
</head>
<body>

<?php
$con = mysqli_connect('localhost','root','','test');
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"test");
$sql="SELECT * FROM tb_user";
$result = mysqli_query($con,$sql);

echo "<table>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
    <th>Hometown</th>
    <th>Job</th>
    </tr>";
    while($row = mysqli_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['firstname'] . "</td>";
        echo "<td>" . $row['lastname'] . "</td>";
        echo "<td>" . $row['age'] . "</td>";
        echo "<td>" . $row['hometown'] . "</td>";
        echo "<td>" . $row['job'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    mysqli_close($con);
?>
</body>
</html>

Kode di atas mengandung semua bahasa pemrograman client side yang telah saya sebutkan sebelumnya (HTML, Javascript, dan CSS), dan juga bahasa pemrograman server dan database : PHP dan MySQL. Mari kita lihat bagaimana kode di atas jika telah diterima oleh client.

Pertama – tama, karena saya telah menyisipkan kode Javascript yang berisi fungsi Alert, Google Chrome menerjemahkannya dengan alert yang harus ditampilkan pertama kali sebelum menampilkan semua content lainnya. Sekarang mari kita lihat respon apa lagi yang akan ditampilkan ketika saya klik OK pada alert box tersebut.

Dari gambar di atas, kita dapat melihat bahwa tidak ada lagi kode PHP atau MySQL sedikitpun yang dapat dilihat oleh end user. Yang kita lihat adalah kode client side seperti HTML, Javascript, dan CSS berdasarkan bagaimana kita membuatnya di PHP. Tabel yang ditampilkan telah dimodifikasi tampilannya oleh CSS, dan isi tabelnya pun seolah – olah diketik manual pada kode yang kita buat, padahal isi tabel tersebut murni mengambil dari database MySQL yang sangat dinamis tergantung isi pada MySQL.

Itulah pemahaman mendasar mengenai bagaimana script server, client, dan database berkolaborasi di pemrograman web. Saya rekomendasikan Anda untuk mencoba sendiri program di atas untuk lebih memahaminya. Setelah ini, saya akan mengupload post mengenai pembelajaran masing – masing bahasa pemrograman secara lebih mendalam. So, keep learning and don’t forget to code.

12.993 comments

  1. fD0mK1fW1H8

    fantastic issues altogether, you just gained a new reader.
    What may you suggest about your post that
    you made a few days in the past? Any certain?

  2. bet india

    I’ve been exploring for a bit for any high-quality articles
    or weblog posts on this sort of house . Exploring in Yahoo I at last stumbled upon this web
    site. Reading this information So i’m satisfied to show that I have an incredibly excellent uncanny
    feeling I came upon just what I needed. I most indubitably will make certain to
    do not omit this website and provides it a look on a continuing basis.

  3. https://znr06rqbutwg.blogspot.com/

    You made some decent points there. I looked on the net for additional information about the issue and found
    most individuals will go along with your views on this site.

  4. 카지노

    I have been browsing on-line more than three hours nowadays, yet
    I by no means discovered any fascinating article like yours.

    It is lovely worth sufficient for me. Personally, if all website owners
    and bloggers made good content material as you did, the web shall be
    a lot more helpful than ever before.

  5. Mpezamihigo

    I’m not sure where you are getting your info, but good topic.

    I needs to spend some time learning much more or understanding more.

    Thanks for great information I was looking for this information for my mission.

  6. オンラインカジノ

    You really make it appear so easy along with your presentation but I to find this topic to
    be really one thing which I think I’d never understand. It kind of feels too complicated and very vast
    for me. I’m having a look ahead in your subsequent
    post, I will try to get the grasp of it!

  7. casino trực tuyến

    Hmm is anyone else encountering problems with the pictures on this blog loading?

    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  8. https://av3f4s5ev.blogspot.com/

    Excellent blog here! Also your site loads up very fast!
    What host are you using? Can I get your affiliate link to your host?
    I wish my site loaded up as fast as yours lol

  9. https://markeharlandxxa.blogspot.com/

    You’re so awesome! I don’t think I’ve read a single thing like this before.
    So wonderful to discover someone with a few unique thoughts on this subject matter.
    Seriously.. thank you for starting this up. This site is something that’s needed on the web, someone with some
    originality!

  10. Kinky

    We are a group of volunteers and opening a new scheme in our community.
    Your site provided us with valuable info to work
    on. You’ve done an impressive job and our entire community will be grateful to you.

  11. 7Bit Casino

    I’m really enjoying the design and layout of your blog.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often.
    Did you hire out a developer to create your theme?
    Outstanding work!

  12. 블랙잭

    I like the valuable information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly.
    I’m quite sure I will learn a lot of new stuff
    right here! Best of luck for the next!

  13. คาสิโนออนไลน์

    That is a really good tip especially to those fresh to the
    blogosphere. Short but very precise information… Many thanks for sharing this one.
    A must read post!

  14. ผลหวยฮานอย

    hello there and thank you for your information – I’ve definitely picked
    up something new from right here. I did however expertise several technical
    points using this website, as I experienced to reload the website lots of times previous
    to I could get it to load properly. I had been wondering if your web host is OK?
    Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your quality score if ads and marketing with Adwords.
    Well I am adding this RSS to my e-mail and could look out for a lot more of your respective exciting content.
    Ensure that you update this again soon.

  15. 더나인카지노

    I don’t even know how I ended up right here, but I assumed this post
    used to be great. I do not understand who you might be but definitely you’re going to a famous blogger if you happen to
    aren’t already. Cheers!

  16. minecraft servers

    Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam remarks?

    If so how do you protect against it, any plugin or anything you
    can recommend? I get so much lately it’s driving me mad so any
    help is very much appreciated.

  17. https://eikx0ee2bf.blogspot.com/

    My spouse and I stumbled over here coming from a different website and thought I may as well check things out.
    I like what I see so now i am following you.
    Look forward to checking out your web page again.

  18. idn poker 88

    I was curious if you ever thought of changing the page layout of your blog?
    Its very well written; I love what youve got to say. But maybe you could
    a little more in the way of content so people could connect
    with it better. Youve got an awful lot of text for only having 1 or two images.

    Maybe you could space it out better?

  19. 地獄少女 スロット

    Every weekend i used to go to see this web
    site, because i want enjoyment, as this this site conations in fact fastidious funny material too.

  20. Milan

    Thanks for some other magnificent article.
    Where else may anyone get that type of info in such a perfect
    way of writing? I’ve a presentation subsequent week,
    and I’m on the look for such info.

    My blog post; Milan

  21. bokep

    Hi, i think that i saw you visited my blog
    thus i came to “return the favor”.I am attempting to find things to improve my site!I suppose its ok to use some of your ideas!!

  22. 바카라사이트

    You actually make it appear really easy with your presentation but I find this
    topic to be really something that I believe I’d by no means understand.
    It seems too complicated and very extensive for me.
    I’m having a look forward for your subsequent publish, I’ll attempt to get the dangle of it!

  23. poker face

    I constantly spent my half an hour to read this blog’s articles or reviews everyday along with a mug of coffee.

  24. 더킹카지노

    This information is priceless. When can I find out more?

  25. Daftar Situs Judi Online

    Faѕilitas pembantu lainnya cantik customer service judi online akᥙ nan profesional selanjutnya rɑmah,
    tersuguh online 24 arloji standby menjumpai membantu kontestan dalam melewati segenap rintihan. Bagi pemuka nan hendak berpadu,
    ego bisa menjadi kota pelabuhan slot online cagaran kalian menurut bertindak judi slots online.

    Jika Anda alpa eka pengagum qq online tentu ada sejumlаh lokasi
    slot online nan tidak langka paԁa temukan Anda.
    Mungkin Anda benar-benar wajar menghabiskan uang lebih, tapi itu tidak sеimbang per hadiah ϳackрot slоt nan bisa mencapaі ponten miliaran rupiah.
    Tentunya, semua jackpot terbesar bisa Anda mudah menangkаn ⅾengan tidak perlu kali lama menjelang
    membela jackpot bermula keluarga atraкsi slot apapun yang dimainkan dekat situs judі online slot terbaiк
    pula terpercaya 2021 paⅾa Indonesia. Dengan semua keuntungan nan diberikan One Touch, cengkeram
    sama menyɑndang pintᥙ lebiһ baik mendapatkan memimpin kеkayaan semenjak iming-iming mereka.
    Karakteristik ρenyaringan berbasis regіster hitam
    domisili IP dengan daerah nisbi ѕifatnya tetap/tidak bertukar
    untuk hasrat tempo nan pаtut lama sеhingga tidak membutuhkan pangkal enerցi yang besar bakal pengejawantahan.

    my blog post Daftar Situs Judi Online

  26. imovie news music

    Hello colleagues, pleasant article and fastidious arguments commented at this
    place, I am actually enjoying by these.

  27. https://769jjhpau4.blogspot.com/

    I all the time used to read piece of writing in news papers but now as I
    am a user of net thus from now I am using net for posts, thanks to web.

  28. Gangbang

    Hi there this is kind of of off topic but I was wondering if blogs
    use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted to get advice from someone with experience.
    Any help would be greatly appreciated!

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *