473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to display login option when clicked on a button without signing in?

36
Suppose I have two buttons for comment and like ,
i need to display "Please login to comment/like "
with login button shown to users if they havn't logged in .

How do i do that ?
Feb 1 '13 #1
6 1644
Dormilich
8,658 Expert Mod 8TB
usually you do that on the server side by checking, whether the user is logged in (which is usually stored in a session variable).
Feb 1 '13 #2
yateesh
36
Okay , but on button click it should check whether the session is set or not and display the message . That requires javascript i think .
Feb 1 '13 #3
Dormilich
8,658 Expert Mod 8TB
it doesn’t *require* JS (though you *can* do it with JS).

what really is required is the answer from the server. if you do that via an HTTP Request by a page (re)load or an HTTP Request by AJAX doesn’t matter to the server. and the question "is the user logged in?" can only be answered by the server.

although, whether a session is established can be determined by JS without the server, you just need to test, whether the session cookie exists. however, that doesn’t tell you whether the user is actually logged in …
Feb 1 '13 #4
yateesh
36
A php page needs to be executed to check if session is established. Can this be done by loading that page into a div that contains login form through js onclick function ? So that it displays login form if session isn't established .
Feb 1 '13 #5
Dormilich
8,658 Expert Mod 8TB
you don’t need to load the page itself into a <div>. and checking for the session itself (note: session != session variable) doesn’t tell you whether you still need to log in.

essentially, if you want to use AJAX to test for a login that’s possible and then you can use any JS means (i.e. event) to trigger the AJAX Request to the server.
Feb 1 '13 #6
yateesh
36
Thank you . Have to deal with jquery and ajax now for that .
Feb 1 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Oskar Wild | last post by:
Hello, how do I code it to display a select (pulldown) box only if the user has selected a certain option in another pulldown box? <select name=country> <OPTION value="France" SELECTED>France...
0
by: kc | last post by:
I'm using a Repeater to display a series of lines, each containing a date and two images, one for Word and the other for PDF. Both images display their respective documents, in new windows, when...
2
by: yatharth | last post by:
I am facing a problem ,the situation is like this. I have a home page named "Index.html" ,on which there is login link,when i click on the login link the login popup opens and user enter the...
2
by: Krista Lemieux | last post by:
Hello, In my form I have a button, and the button_Click function (which gets called when the button is clicked). However the functionality that I have in the button_Click function, needs to be...
2
by: Humberto Alvarez | last post by:
Hi All I'm using asp requiredfieldvalidator and regularexpressionvalidator to validate a text field and a file input field respectively. The validation messages (the text property of the...
2
by: Rob Roberts | last post by:
Is there any way to prevent a ButtonField in a GridView from doing a postback when clicked? I want to use my own onclick handler to call window.open('SomePage.aspx') to display a page in a new...
1
by: leovega | last post by:
Hello, My aplication starts with a simple login window (login_page.aspx). Once the login/password is validated I redirect to an html which contains 3 frames. (mywebsite.html) The web site I...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
2
by: chitrapu | last post by:
hiii everybody, i have a little code that inserts the data into the databse. but the problem is the insertion should be peroformed only when a button is clicked. i have problems in this because i...
1
idsanjeev
by: idsanjeev | last post by:
<%@ Language =vbscript%> <% Option Explicit %> <html> <head><TITLE>VOICE OF BARAUNIANS</TITLE></head> <body> <!--#include file="front.inc"--> <div style="Position:Absolute; width:700; TOP:0;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.