I want to stop a user from clicking a Like button multiple times. I can disable the button on the first click using jQuery, but when the page is refreshed, the user can again click the button. How do I prevent a user from re-clicking the button on page refresh?
you can store the user id in database who have already liked and disable the like button/link for them so they once click on the button or link never click again
use js to block the UI
like so: http://www.malsup.com/jquery/block/#demos
google "js block ui"
sorry for the short answer
edit: did not read your question properly i guess, see Mayank swami's post , he has your answer
You should check it in Server side.
use can use $_SESSION for this purpose.
When user click on link set
$_SESSION['liked']=true;
and then check if user clicked before. Session won't be destroyed in when page refreshed.
Related
I need to know how I can process the SSO login without reloading the page.
My sample link is http://abmprograms.com/tdr/disqus.php
When I click on the first option to login a pop-up opens, if I either try to login with below details (see my comment below) or close it the page reloads.
Is there anyway to prevent this?
Looks like you are using, jquery. Have you tried using modal forms: http://jqueryui.com/dialog/#modal-form
You can control the login form post using javascript which would let you control the modal form behavior.
I am stuck with a problem. I am not finding further way. Please help me out with the logic.
I have page1.php besing used by user1 and have page2.php used by user2.
Now when the user1 clicks on a button in the page. The page2.php which is being viewed by user 2 must be refreshed. How can I do that.
Your help is most appreciated.
Thanks!
Abhilash
You cannot do it in php. Once the page is loaded, PHP dies and is out of control.
You have a few options:
Use javascript
Use the refresh meta tag
I think that the refresh meta tag is the most easy and convenient.
you can do it by using php ajax and javascript \ jquery
just save the click button flag in database, and by using php ajax continuesly check wether the button click flag is on or off,
if it is on than you can refresh the page by using javascript.window function
My client wants, when customer loges in, he should be prompted to select a page (i.e admin or home) where he will be redirected, is it possible?
I guess you should use something like: http://jqueryui.com/demos/dialog/ and ask the user while she on your page what is the next page (admin/home).
If loggin successfully ,you can trigger a popup like something having some options for admin,home ,just links would be great
sample http://jqueryui.com/demos/dialog/
You may call a popup page with the combobox in it on load of the Login Page.
Demo : http://jqueryui.com/demos/dialog/
The page which he logs in make it as a selector dummy page.
means the page does nothing but display of combobox and handle the redirect.
login.php->redirect.php->admin.php or home.php
you can either do this by spiting up the entire page section with a php request method.
Or you can give a option where the user can select the page form the login panel it self in that way you can easily do the page redirection.
I am trying to build a web app like this using php, it has two pages:
select.php has some radio buttons in a html form for users to choose. and there is a submit button post the form to a confirmation page.
confirm.php echos the summery from previous page and there is a "back" button allow users to change their selections in the previous page.
In this point, when I hit the "back" button and previous page restored, I would like all my previous selections displayed. (more clearly, if I chose a radio button and submit in select.php, I want the radio button still being chose after I go back to select page by hitting "back" button from confirm.php page.)
Please give me some idea about how to do this kind of restore page thing.
Save your selection in session.
In select.php pre-select the radio buttons if its found in session.
BTW, You should not rely on back button of browser. Create you own back button on confirm.php page. This back button will go to select.php using no history.back()
The HTTP-Protocol is stateless.
So when calling select.php the server doesn't know anything about your previous selection.
You can either save the selection in the session or in a cookie and restore in in selection.php
I have a PHP data entry page and redirecting to the new page after data inserted successfully. But the user can go back using the Browser back button and click on the 'Save' button again. Is there any way I can prevent this kind of problem? Please suggest. Thank you.
I am using the following code to redirect.
header ("location:Redirect.php?ref=10");
Yes, you can store a variable in their session whenever they click the button then use this to show/hide the button accordingly by checking that session variable. Also if it's set then do not allow posting/processing of the form.