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 4 years ago.
Improve this question
I want to INSERT data into my MySQL database.
After some research I found out I can use something called Node.js to do this.
But it seems to complicated for this small thing I want to do.
Is there a way to do this only with JavaScript, without Node.js?
Background: In my web-based iOS app I want to integrate a Favorite button. When the user clicks on the Favorite button on any site some data get stored in my MySQL database (user id, favorited webpage, title of webpage) and the Favorite button changes its color to signal it's favorite and put in the favorite section.
Following problem if doing this with PHP and not JavaScript: The user have to click the Back button twice to get out of this page, because reloading for storing in the database created a new entry in browser history.
Or is there another solution to prevent to the user have to click the back button twice to get out of this page?
Applications which runs on the end-users machines should never-ever have direct database access. Create a REST API with PHP (if you already using it) which handles the database operations and invoke it with JavaScript (this is the short explanation of AJAX).
Related
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 3 years ago.
Improve this question
I am developing a webpage with Python(Django) and want to restrict users from to be able to bookmark a specific web page. Is there a solution?
Bookmarks are Browser specific and you cannot intervene with what the user can do with the browser outside of your web application.
If you do not want the user to access the webpage directly, you can implement Authorization with Session IDs to prevent direct access to the specific webpage.
The answer is no, the user can always bookmark a page because it is a browser function.
But you can use sessions. Then make sure that any page request must have an active session ID, otherwise, it will return an error or redirect to the home page.
The user can add a bookmark to the page, but the bookmarks will only work for limited time. He won't able to access the page after the session timeout. This also has the added benefit of making the site impossible to index by the search engines.
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 4 years ago.
Improve this question
I was just wondering how do I make my website preview some info after the user searches for something stored in the database.
Basic approach for previewing user names as you type in a search bar. For this to work, you will need to use AJAX to query the server and also display the result as a preview for the user to click on if they want, without having to refresh the page.
User types 'Joe' into the search bar
The onChange() even is fired and you query your server with that the user has written "Joe". Keep in mind this query is via AJAX, so as not to force the page to reload.
Server side, you do a MySQL lookup of the table users, where the name is something like "Joe". SELECT NAME FROM USERS WHERE NAME LIKE '%what_you_sent_on_AJAX_request%' LIMIT 10;
The browser receives the response from the AJAX request and displays a nice dropdown with the output of the server. When the user actually click son this "previews" it is in that moment that you would actually reload to the page or take the user to a new page based on what they have clicked on.
That's a very basic approach for it.
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 4 years ago.
Improve this question
I have a requirement where, Users inputs something and submit then angular does a service call which returns if users input is valid/invalid. If valid take user to success page, if service returns invalid/bad input then user needs to be taken to failure page and should never be able to go back(using back button) or user refresh the page, user should still be on same page. Only option provided to the user should be close browser, there by not allowing using to submit one more request(leading to service call).
You cannot prevent the user from not running or editing client-side JavaScript code. Since this is a security requirement against the interest of that particular user, the solution must be server-side:
On the server, after getting the wrong answer, mark the user's profile as such. You may need an additional table in your database joining users and questions for that.
Whenever the user loads the question or submits it, first check the user's flag. If it's set, error out immediately.
Note that this behavior is quite hostile to the user. For instance, the user may accidentally touch Enter too soon, and will be shut out by your system.
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 6 years ago.
Improve this question
I want my users to be able to view content on my website, and when they see content they like (My website randomly generates content using JQuery.load() ), I would like them to be able to store it onto a personal page that they have to log in to, to see.
My page loads content with the line:
$(".resultContent").load(skillList[skillChoice]);
The variable "SkillList" is assigned "skills.html #id"
the '#id' part is identifying a <div>, and that's the part I want to be stored, and I want the user to be able to store multiple parts of the page skills.html on their personal page.
This sounds fairly complex, but I was wondering if it's doable, if so, what language(s) would I need to use?
You will need to save those html snippet on the server, mostly likely in a database. This can be done by client-side javascript, an ajax POST. The server side can use any language.
Since you are saving some html on the server and will load that in a page. The server side must sanitize the html snippets for security.
When the html snippet is saved, the server needs to know who sends the request. That is the user needs to log in before or when s/he saves the content for later use.
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 6 years ago.
Improve this question
I have 10 records in json array that comes from api call. But I need to show only 1 record on webpage providing next and previous buttons. So when user clicks on next or previous buttons I need to fetch the next or previous records and display on webpage. Something like viewpager in android or flipview in windows apps.
The reason why I want to store is just to avoid unnecessarily api calls to server fetching record and also pointers to next and previous record.
Is it possible to store those 10 records in some javascript variable and keep iterating when user clicks on next and previous.
Server side I am using laravel 5.2
Of course it can be done. Just format your JSON correctly to hold an array of records, and maintain an index pointing to the current record.
To update the display you can either use pure JavaScript or utilize some kind of MVVM library (for example) like Knockout or Angular.