Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What are the pros and cons of different methods of including data from a database on your webpage?
From my understanding I have two options. A html page, with JavaScript (or other browser language) that fetches and includes data. A php script (or other server based program) that builds and outputs an html page with the data already included. But how am I to made the decision between the two?
Always go for PHP when using a database. It is a more robust and proven technique.
Also PHP pages are protected by the server and nobody can see how the code works, they only see HTML output, whereas with Javascript anyone can see your code.
After all I don't know how JS supposed to interact with data, maybe store data in an XML page and then retrieve them, not sure. Why invent a wheel when you have PHP which is supposed to work with databases unlike JS which is designed mostly to be an improved front end functionality, unless its back end JS, but few people use JS that way.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am using https://pavlovia.org to run some experiments in behavioral economics in risky-choice. The task requires the subjects to play (or not) different lotteries. The system creates javascript files which it runs on the subject's browser. However, I found it very easy to inspect and edit the javascript which would allow a malicious subject to give themselves an advantage (e.g. increase the probability of a lottery paying out).
If someone makes all the lotteries "win", it will be easy to tell they cheated, but if they boost the probabilities by a small amount it will be very hard.
Other than re-writing everything so that the logic is server-side, I wondered whether it is possible to compute a hash (md5 or sha) of the JS code on the client and sent it back to the server to check wither the JS has been edited. I found several posts related to computing hashes in javascript, but I wasn't sure whether a file could compute its own hash.
I appreciate that a sophisticated user could also hack that part of the code (e.g. copy the original file to another name and then edit the code that takes the hash to point to the original file, or something like that). But i wonder if this technique could be one more barrier to cheating.
The user has the ability to debug the JS code while running and replace values in some variables. Even if JS hashing was possible, it would not prevent that. I believe there is no other way than making part of the crucial logic on the server side.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a page that uses javascript for computing inventories.
I use PHP as my server-side language for saving to MySQL.
What is the proper practice when it comes to this situation:
Use only php to compute then save to DB.
Use only javascript to compute then use PHP to save to DB.
Or should I use both to compute? Please help. Thanks
Use javascript for dynamic data calculations or adjustments client side without the need of refreshing the page. This is good if you are wanting to do on the fly calculations quickly in the clients browser
Use php for validating and formatting your data before saving into your MYSQL database. Make sure only send the raw inputs to your php script and do the calculations again with php server-side. Sending the computation result done with JS would be super risky as client side processing is easily manipulable by users.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
So I recently stumbled upon jscrambler.com
This tool actually allows you to protect your javascript code, its fascinating. However, the service is cloud based and im wondering if this is really ok. Since im actually posting code on their servers. While others cant steal my code, it is still vurnerable to theft from within the the guys behind jscrambler.
Maybe im worrying too much. Is it safe to use jscrambler services?
You're right. Giving your code to a 3rd party to protect it is as counter-productive as it is counter-intuitive.
That said, browser users always have access to the underlying Javascript code. The most you can do is wrangle the source code by making syntactic changes that produce the same functionality but result in harder-to-read text.
This process is known as uglification or minification (since it reduces file size). UglifyJS is the most frequently used tool for this.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm working to a project and my aim is to create an html page to view the train/bus/tram timeboards.
So there is one html page for back-office(for the company) and one page for front-office(for the customers).
The company wants to change files in the page (pdf/links that can be viewed inpage) from back-office.
How can i manage the informations between back-office and front-office by using some simple stuff/programming languages?
Anyone has an idea?
Substantially I want to do something like this for front-office view:
http://codepen.io/anon/pen/NGxrQp <--Check this
OR
http://jsbin.com/mawevuwi/1#tab4
And then something more simple for back-office.
PS: I'm new at stackoverflow and sorry for my bad english explanation.
A back-office should be able to add, edit or delete content. Therefor you should use dynamic webpages, not static. You can use a database to store values. Make the front-office read-only and you're done.
You could also use a Content Management System (CMS) like WordPress.
Some more info:
A static webpage only shows what's in the files. A dynamic webpage could show you generated data or data not in the file itself but from a database for example. Databases use SQL (Structured Query Language). The 4 operations are abbreviated as CRUD:
Create
Read
Update
Delete
I recommand you start learning SQL & PHP if you want to continue with this. Other languages (rather than PHP) are possible.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm making a website for a client that will mostly be used offline through a wifi router. But there will also be an online version available. The purpose of this is to distribute files in parts of the world where infrastructure is not suitable for internet access. For those who do have internet access in some of these parts, the internet probably isn't very fast or reliable.
Some of the pages I've made can be accessed simply by using JS functions to hide one page and show another, instead of anchoring to another file. I figured this method might load content quicker, rather than linking to multiple pages. But is that true? Or should I just put all the content on separate pages?
Yes, that's true, but most browsers doesn't load a page if they don't get an answer, so you'll need at least one local server. You can store almost everything (style, script and content) in localstorage, store as strings and eval if/when needed. Also, if local processing isn't a problem you can use AngularJS to build and rebuild the page.