#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.

2.555 comments

  1. best-credit-repair-companies

    Hi there, You’ve done an incredible job. I will definitely
    digg it and personally recommend to my friends.
    I am sure they’ll be benefited from this site.

  2. Publikace_od_75_Kc

    Hello there! I could have sworn I’ve been to this website before but after going through
    many of the articles I realized it’s new to
    me. Anyhow, I’m definitely happy I came across it and I’ll be bookmarking it and checking back regularly!

  3. quick food recipe app

    Hello there! I simply want to give you a big thumbs up for your excellent info you have got right here
    on this post. I’ll be coming back to your site for more soon.

  4. jual view youtube

    Today, I went to the beach with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely
    off topic but I had to tell someone!

  5. Liverpool

    Hey! I realize this is sort of off-topic but I had to ask.
    Does operating a well-established blog such
    as yours require a massive amount work? I am completely new to writing a blog but I
    do write in my journal everyday. I’d like to start a blog so I can share my experience and feelings online.
    Please let me know if you have any ideas or
    tips for brand new aspiring bloggers. Thankyou!

  6. xxx mom son Fuck HD movies

    This design is incredible! You obviously know how to keep a reader entertained.

    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.

    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

  7. car battery replacement service near me

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

  8. Fresh Prime Keto

    Hey! Do you know if the make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everythin I’ve worked hard on. Any
    recommendations?

  9. wiki

    As the admin of this site is working, no hesitation very soon it will be famous, due to its quality contents.

  10. FinANce

    I believe everything published made a ton of sense. However, what about this?
    what if you were to write a awesome post title? I am not suggesting your information is not solid,
    but suppose you added a post title that makes people want more?
    I mean #2 Tutorial Pemrograman Web – Konsep Dasar PHP, HTML, MySQL,
    Javascript, CSS – Dryan Christoph Personal Website is kinda boring.
    You ought to look at Yahoo’s home page and note how
    they create article titles to get viewers to open the links.

    You might add a related video or a related picture or two to grab readers interested about everything’ve got to say.

    Just my opinion, it might bring your posts a little bit more interesting.

  11. bateri kereta kong

    What’s Happening i’m new to this, I stumbled upon this I’ve discovered It absolutely helpful and it has helped me out loads.
    I am hoping to contribute & assist other customers like its aided me.

    Great job.

  12. data sgp

    When someone writes an piece of writing he/she keeps
    the plan of a user in his/her brain that how a user can understand it.
    So that’s why this article is perfect. Thanks!

  13. may chu

    Your style is unique compared to other people I’ve read stuff
    from. I appreciate you for posting when you’ve got the opportunity, Guess I will just book mark
    this web site.

  14. agen ibcbet

    Hurrah! Finally I got a weblog from where I be able to in fact obtain helpful facts regarding
    my study and knowledge.

    Also visit my web site :: agen ibcbet

  15. financial planner around me

    A fascinating discussion is worth comment. I do think that you ought to write more on this topic, it may not
    be a taboo subject but typically people do not talk about these issues.

    To the next! Best wishes!!

    Also visit my website – financial planner around me

  16. financial advisor near me reviews

    I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored material stylish.
    nonetheless, you command get bought an impatience over that you
    wish be delivering the following. unwell unquestionably come more formerly again as exactly
    the same nearly very often inside case you shield this
    increase.

    Here is my blog post – financial advisor near me reviews

  17. 광주출장안마

    Do you have a spam problem on this website;
    I also am a blogger, and I was wondering your situation; we
    have created some nice methods and we are looking
    to swap strategies with others, please shoot me an email if interested.

  18. chứng minh tài chính đi du học

    Its like you read my mind! You appear to know a lot about this, like
    you wrote the book in it or something. I think that you
    could do with a few pics to drive the message home a bit, but instead of that, this is wonderful blog.
    A fantastic read. I will certainly be back.

  19. webpage

    My partner and I absolutely loive our blog and find many of your post’s to be just what I’m looking for.
    Would you offer guest writers to write content for you?
    I wouldn’t mnd creating a post or elaborating on a few of the
    subjects youu write in relation to here. Again, awesome web log!

    webpage

  20. click here

    Hello there, I found your website by the use of Google at the same time as
    looking for a comparable subject, your site
    came up, it appears to be like good. I’ve bookmarked it in my google
    bookmarks.
    Hello there, simply was alert to your weblog via Google, and found that it is really informative.
    I am going to be careful for brussels. I will be grateful should you proceed this in future.
    Numerous other people can be benefited out of your writing.
    Cheers!

  21. idnpoker.com

    Thank you a lot for sharing this with all people you really realize what you are speaking approximately!

    Bookmarked. Kindly also consult with my website =).
    We will have a hyperlink alternate contract among us

  22. 일산출장마사지

    Hello, i think that i saw you visited my web site so i came to “return the favor”.I’m trying to find things to
    enhance my site!I suppose its ok to use some of your ideas!!

  23. joker123

    After I originally commented I appear to have clicked the -Notify me when new comments are added- checkbox and from
    now on each time a comment is added I receive 4 emails with
    the exact same comment. There has to be a way
    you are able to remove me from that service? Appreciate
    it!

  24. Verona

    Et la fertile déclin contient maint mitochondries et
    de fer (c’est pourquoi elle levant crépuscule), avec sien mission est moyennant
    produire par la frénésie. L’étude gloriole qu’une jatte comme bouchon ou aussi caféine
    peut dans nature pousser cette charnu brunante dans usiner quant à la engouement.
    Les adolescents gardent pour cette licencieux déclin vu qu’ils non peuvent seuil vibrer puis fabriquer pendant la moiteur.
    Nous non savions même allure que une huile brune vivait jusqu’à celui-là y a 10 siècle.
    On a trouvé moyennant une graphite déclin parmi lésine adultes,
    tablier pendant lequel la morceau supérieure par la blouse.
    « Nous avons complets ce camaraderie parce que effusion ultérieurement tenir
    bu la jatte moyennant bar, pour moi-même stimulons cette oléagineux soir « , prévu le pédagogue
    dans l’origine contre une paysage.

Tinggalkan Balasan

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