Jump to content

How Web Code And Server-side Code Work Together


c0dege3k
 Share

Recommended Posts

I'm interested in a starting up a website and am just wondering how the code of the actual website (HTML, Javascript, etc) works with server-side scripting (PHP/MySQL, ASP(I think)). I'm trying to learn it all on the w3schools site, but finding it rather confusing.

Thanks for the help ahead of time.

Link to comment
Share on other sites

Server side code works in combination with the regular html, css, javascript etc. In cases like PHP, you cna have the PHP generate the entire page with no direct html or you can have it do both. Just know that its like any other code you put in the page to make stuff happen, only server side code can do more stuff on the back end of the server to pull data or even run against the OS itself, say to access a specific program for crunching data.

Give you an example. Say you have stuff stored in a database. You want to pull certain data from the tables, you would use something like PHP to write a query for the data and then render it, while using the HTML and CSS to display said data within the page how you want it to look in the browser. Another example, if someone needed to login to a site, you would have an HTML FORM that POSTS the user name and password to a PHP page, that would then look up the information in its database and upon validating, return the results to either allow or deny the user to login to the site.

In the old days, it was all done with things like CGI scipts, where you wrote little perl scripts that processed form data. Today, things are a bit more dynamic, and can use a combination of languages to work in real time, such as PHP, XMLHTTP requests, Ajax, and so on without ever leaving a single page and returning the data in the page on the fly.

ASP is generally found on Windows Servers, PHP can be on many different platforms, and for the most part, its code is cross platform (independent of the OS) and will run anywhere, so long as the servers all have the same base version it was written for(ex: php4 vs php5). MySql itself is an open source database and is usually used with PHP, but it could also be any other number of databases on the backend, such as PostgresSQL, Oracle or even Microsoft's SQL server.

Link to comment
Share on other sites

  • 1 year later...

yeah, that's a really complex question.

and it's kinda specific to what lang your using.

but say, in php, there are lots of ways to go about it.

you could have a .php file with a mix of html and php

<html>
<body>
<p> today's is: 
<?php
  echo date('l jS \of F Y h:i:s A');
?>
</p>
</body>
</html>

or you could use a templating system that

loaded vanilla html files and processes

them with php (usually replacing strings

with php variables at run time).

javascript is a common "front end" language,

but with the advent of node.js

you can use it as a backend lang as well!

in asp.net (this is just one example)

you have two files for ever "page"

(e.g. home.aspx + home.aspx.cs)

the aspx file is basically HTML, js, css, etc.

but aspx.cs is a c# (c sharp) file that

has the "code behind" the other file. it can

use the other file as a template if desired.

but like i said, that's just one example.

some people like to mash both those two

files into one in .NET, and that's cool.

coding is about personal style (to a point).

it's good to have standards, and best

practices (if they are from learned experience

not just "company policy").

Link to comment
Share on other sites

  • 2 weeks later...

I'm interested in a starting up a website and am just wondering how the code of the actual website (HTML, Javascript, etc) works with server-side scripting (PHP/MySQL, ASP(I think)). I'm trying to learn it all on the w3schools site, but finding it rather confusing.

Thanks for the help ahead of time.

Rather than trying to lean all at once, I would suggest to start from one end of the string then slowly progress to the other. First start with HTML, get to know the language, how it works, how you can use it to manipulate the way a page looks on your browser. Once you've decided you know enough about HTML, move onto Javascript.

Javascript can be a very confusing language to learn at first, so take your time to learn it and practice as you go along. As opposed to PHP or ASP, Javascript runs on the client's side or when the page is loaded by the browser, since it runs on the client's browser, it does NOT rely on a web server to run the code for you.

The good thing about HTML and Javascript, is that they don't require any server side configuration, its more like plug and play, you drop the code into your webpage and the browser executes it for you. As for PHP and ASP you will need a webserver such as IIS or Apache configured to serve .asp or .php pages.

If you want to learn how to develop dynamic webpages, I'd recommend PHP instead of ASP. From experience, its a lot easier to learn, also there are plenty of Tutorials and guides on the internet, which will make the learning experience for you, a good one.

Edited by Infiltrator
Link to comment
Share on other sites

See also: http://w3fools.com/

And delete your bookmarks to w3schools.

Meh, for someone starting out, its a decent place for beginners. I wouldn't say its an "industry standard" but its helpful, even if it is not related to the official W3C, I myself still use the site when I forget things. Knowledge is Knowledge, and while not everything on their site is 100% accurate or up to date, its still a valid place to use for reference and dive into something you know nothing about. Even php.net can be confusing at times, showing code that is either outdated or deprecated depending on what function you get from your search results and things aren't always the same between operating systems in how they render or what the requirements are for certain characters in syntax, but hell, I still use it too.

There is more than one way to skin a cat...At the end of the day, if you can't figure something out, work on your google fu and you should fine an answer somewhere. Just know that copying and pasting code you don't know what it does, can also make your stuff insecure, and all the sites that give examples on coding for the most part, tend to have this problem, since so many people just reuse whats easily found on the internet without knowing its vulnerable code.

Link to comment
Share on other sites

Meh, for someone starting out, its a decent place for beginners. I wouldn't say its an "industry standard" but its helpful, even if it is not related to the official W3C, I myself still use the site when I forget things. Knowledge is Knowledge, and while not everything on their site is 100% accurate or up to date, its still a valid place to use for reference and dive into something you know nothing about. Even php.net can be confusing at times, showing code that is either outdated or deprecated depending on what function you get from your search results and things aren't always the same between operating systems in how they render or what the requirements are for certain characters in syntax, but hell, I still use it too.

There is more than one way to skin a cat...At the end of the day, if you can't figure something out, work on your google fu and you should fine an answer somewhere. Just know that copying and pasting code you don't know what it does, can also make your stuff insecure, and all the sites that give examples on coding for the most part, tend to have this problem, since so many people just reuse whats easily found on the internet without knowing its vulnerable code.

W3Schools is known for having misleading, confusing, ill-advised, or just plain incorrect information. They might occasionally have a bit of useful information here and there, but the same could be said of monkeys and typewriters.

At the end of the day, the point is why continue to propagate a resource that is known to be dangerously flawed when there are plenty of clear and accurate alternatives which provide more and better information? This is why that page is called an intervention, you need to break yourself of the habit. Every time you recommend W3Schools (or allow someone else to use it as a resource without informing them of these issues) you are doing EVERYONE a disservice. Every wonder why there are so many horrible, broken, ugly, and insecure web pages all over the Internet? It's due, in part, to resources like W3Schools which teach people bad habits and insecure patterns.

You're right, there is more than one way to skin a cat. And the W3fools.org page lists at least a half-dozen better ways to do it. So why defend and promote the method that is known to be less effective and more dangerous? Defending W3Schools, in this case, is like defending bloodletting on the grounds that it was occasionally useful to the leading physicians over a century ago.

Link to comment
Share on other sites

W3Schools is known for having misleading, confusing, ill-advised, or just plain incorrect information. They might occasionally have a bit of useful information here and there, but the same could be said of monkeys and typewriters.

At the end of the day, the point is why continue to propagate a resource that is known to be dangerously flawed when there are plenty of clear and accurate alternatives which provide more and better information? This is why that page is called an intervention, you need to break yourself of the habit. Every time you recommend W3Schools (or allow someone else to use it as a resource without informing them of these issues) you are doing EVERYONE a disservice. Every wonder why there are so many horrible, broken, ugly, and insecure web pages all over the Internet? It's due, in part, to resources like W3Schools which teach people bad habits and insecure patterns.

You're right, there is more than one way to skin a cat. And the W3fools.org page lists at least a half-dozen better ways to do it. So why defend and promote the method that is known to be less effective and more dangerous? Defending W3Schools, in this case, is like defending bloodletting on the grounds that it was occasionally useful to the leading physicians over a century ago.

This is an opinion rather than facts that they aren't useful or that they teach bad habits. I learned a great deal from their site back in the day when I first started tinkering with web pages back in 98 and the aol days(not saying I used them way back then, nor do I know if they existed back then) but they offer decent basics to get people started. Again, opinions, and they vary, so may your mileage, but I still use it from time to time for stupid shit when you just forget some little something that you havn't had a need for in decades, like basic html with no css for email readers that for whatever reason still only use HTML 4. It's useful, and w3fools can scream all they want but it doesn't change my opinion of them. I'm not going to try and learn every web dev coding standard from them or think their certification is worth more than a turd, but I recommend it to anyone starting out and stand by that. If you want to dive it, it has usefulness and thats my opinion.

Link to comment
Share on other sites

I agree with Digip, whether W3C has good standards or not, it's quite a resourceful website for beginners to learn stuff from. It may not be the best website on the internet, but it certainly has helped me a lot, when I was learning PHP and it still helps when I forget how to do certain things.

Link to comment
Share on other sites

Did you guys look at any of the resources they recommend instead of W3Schools? W3C was only one of several, and they weren't even recommending the W3C specs, they were recommending the tutorials posted on their Wiki.

I'm glad you guys were thorough enough to actually read the page before jumping to conclusions about it. Is that how you form all of your opinions?

Here's the TL;DR.

http://dev.opera.com/articles/view/1-introduction-to-the-web-standards-cur/#toc

http://code.google.com/edu/submissions/html-css-javascript/

http://reference.sitepoint.com/css

http://www.w3.org/wiki/HTML/Training

https://developer.mozilla.org/en-US/docs

Link to comment
Share on other sites

Did you guys look at any of the resources they recommend instead of W3Schools? W3C was only one of several, and they weren't even recommending the W3C specs, they were recommending the tutorials posted on their Wiki.

I'm glad you guys were thorough enough to actually read the page before jumping to conclusions about it. Is that how you form all of your opinions?

Here's the TL;DR.

http://dev.opera.com/articles/view/1-introduction-to-the-web-standards-cur/#toc

http://code.google.com/edu/submissions/html-css-javascript/

http://reference.sitepoint.com/css

http://www.w3.org/wiki/HTML/Training

https://developer.mozilla.org/en-US/docs

Um, no one ever said not to use those other sources?? I've been to the w3fools site before ever even seeing the link here in this thread too. It gets mentioned on Twitter quite a bit. Site has been around for a while. Just like the MBP and Air get mentioned on how "real" web designers can't be bothered with useless windows machines, should only use a MAC to create graphics, movies and code..../usless snob rant

There is a whole internet of sites out their geared to helping people get started though, many of which show incomplete, insecure, un-sanitized example code too. I just find the site useful, easy to find simple examples, and whether its rated top notch or 100% "standards" compliant is irrelevant to me. I don't consider myself some elitist web programmer, or a code snob, I just like sites that show me what I need when I search for it, and I work the rest out from there.

Let me put it another way. tutsplus.com has a multitude of sites, for various things like photoshop, web design, etc. Envato, etc. They often give code snippets and video tuts on their sites as "web designers" and show how to use code or do shit with specific programs, like photoshop or illustrator. Problem I have with them is, they often limit it to "webkit" based browser code examples, and most of the time, the code, only works in specifics(such as webkit based browsers), as in geared towards Safari and Chrome, even going so far as to use the "non" standard CSS markups such as -webkit-border-radius for rounded corners when the "w3c" standard is "border-radius" by itself and should work everywhere, right, because it is a "standard" created by the w3c. They never bother to mention that mozilla for example has its own prefix, such as -moz-border-radius, or that Opera, used to use border-radius just fine and followed standards, but will also only do certain things these days when it is prefixed such as -o-somesudocode-css-markup meant only for specific opera CSS code.

At the end of the day, you use whatever you can get your hands on, you learn as you go, and at some point, you will outgrow w3schools. And you might even raise your fist in anger when you find a site that has code you want, but only shows syntax for one specific browser, and would require a complete re-write to be all browser compatible. I mean, lets face it, who still bothers to try and make sites load properly in IE6? Javascript and HTC PNG tricks for transparencies? WTF?? Talk about non standard.

I'd rather not argue over stupid shit, but I won't stop recommending w3schools to beginners. That would be like telling someone, better avoid Hak5 forums and only go to the back|track forums, or you might not learn the right way to hack something. To each their own, no hard feelings, but its kind of like browser and OS wars. For me, use what gets your job done(be it WIndows, Linux, Mac, specific software, etc), and be done with it. If its wrong in some way for what your end goal is, you will learn from it at some point and as such, thats how we get better at what we do...

Link to comment
Share on other sites

  • 1 year later...
Posted · Hidden by Sebkinne, April 25, 2014 - necro
Hidden by Sebkinne, April 25, 2014 - necro

ASP is generally found on Windows Servers, PHP can be on many different platforms, and for the most part, its code is cross platform (independent of the OS) and will run anywhere, so long as the servers all have the same base version it was written for(ex: php4 vs php5). MySql itself is an open source database and is usually used with PHP, but it could also be any other number of databases on the backend, such as PostgresSQL, Oracle or even Microsoft's SQL server.

Aaah, yes ASP...the good ol' days! I love Classic ASP before M$ made things more complicated with .NET. I'm shocked no one created a Classic ASP clone to run on *nix.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...