473,757 Members | 10,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP/ Ajax Login without Refresh: Help

5 New Member
:( ::)
Hello there,

I recently started Web Designing with PHP, Javascript and AJAX.

I am facing a problem which I will try to explain:
If I am successful in conveying the problem to you clearly, could you
pl. suggest me some solution? Thank you,
Here is the problem details:

I successfully created a Registration/Login/Logout system with CMS
features by learning through tutorials/forums like yours, using PHP/MYSQL
only. Thanks to the internet.

I want to Ajaxify the code using the Javascript programming and
XMLHttpRequest Object.

So the question I asked to myself is:
Can we login without refreshing the current page? In theory and
practice I am able to validate/check the username , password and get
back the results array from mysql without refreshing the page.

I am facing the Problems after this:
How do I retain myself in that State of LOGGEDIN situation? The answer
to this is(probably): $_SESSION variable.
But at this point I got stuck: Where should I use session_start() and
where should I assign the SESS_MEMBER_ID ? Is it in the index.php
which is the main page (which has the login screen) or is it the 'php
script' which checks for user name, password
and sends back the results. I tried adding the session code to "php
script" under the login submit button. It successfully gives me the
session id.
However, if I refresh the page, I loose that session ID:

so, my doubt is where exactly is session ID stored ? On the server or
on the client machine like a cookie.
How do we retain it ?

Its similar to when I log into yahoo / gmail account, even if I
refresh, I wont be logged out to main screen.
How is this possible without refreshing the form.

Could you pl. help on this.
Thank you very much for your time.
regards,
sincerely,
Prasad.
Feb 16 '08 #1
3 5556
acoder
16,027 Recognized Expert Moderator MVP
Hi Prasad, welcome to TSDN!

You should use sessions on the main page too, so that when the page is refreshed, you don't lose the session.
Feb 16 '08 #2
burrashiva
5 New Member
thank you @acoder.
still I am not fully clear of how to do that.
I have tried similar to your suggestion ie.

I created a main.php which has session_start() , LOGGEDIN= false;
on the main.php , there is a section called loginform, which on receiving username,
password(checks it) then regenerates session ids and then LOGGEDIN is changed
to TRUE.

Now the session should remember TRUE but if I refresh, the session information is lost, the main page come back instead of the logged in TRUE status.
Is there a place on the client computer and server, where I can look for the session id being stored and just confirm myself that it is infact storing the information and checking it during refresh.?

Ofcourse, I am using Logged in Status to hide some content which is generally visible in LOGGEDOUT status.

so, I am confused of how to do this ?
Hope you will clarify me on this ?

thank you for the earlier post and for the time too.

prasad.
Feb 17 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
I haven't tested this, but when you normally start a session on a page without Ajax, you wouldn't set LOGGEDIN to false, would you? You'd check that the username is set in the session variables. The only part you need to "Ajaxify" is the login. The rest should stay the same.
Feb 18 '08 #4

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

Similar topics

5
3408
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's logic, but computer thinks otherwise. I use application("loged") to store the cookies of all users. Here is a code: main.asp
3
2906
by: Beshoo | last post by:
hey gaiz plz I want to cerate log in system in ajax i do it but i have one problem AFTER I start thes session then press refresh key the session gone !!! in other words , after the user type hid username and password I send this information by XMLrequest to php file which verify the user name and the password if trure open the sesstion and get it name 'user' its become like this $_SESSION=$user;
1
2917
by: quill | last post by:
Hi I am making a chatroom script and it appears that the problem seems to be that my setTimeout's are conflicting. The logic is as follows: Run a login check every x seconds Run a trigger check every x seconds
1
5125
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the information to load. Any suggestions on how I might get around that. The articles tab is the tab where the javascript won't load. Thanks so much for any help you might be able to provide: This is what the tabs code looks like: <ul...
25
2549
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
10
3478
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario ------------- I have perl script which simply runs a ps on a Solaris server and generates a static html page with all of the code perfectly and this html page works fine when viewing it statically or with a META REFRESH header tag. The idea is to give the user...
4
5358
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a text field which causes the Autocomplete extender to display 10 like items, after the users selects an item (which is a key in the database) I want the application to go to the database retrieve a record and populate the fields.
2
2255
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data, and a javascript file to to the clever stuff. when i access the html page, all the data is displayed correcty, but if i add or delete any records, and press the button i have created to refresh the data(without reloading), the data doesn't change....
6
9829
by: KDawg44 | last post by:
Hi, My responseXML is always null on my AJAX call. When I browse directly to the PHP script I am calling, the XML file shows up just fine. I have read that if a returned XML file is not valid, it will always appear as null. I am just returning some basic XML like: <?xml version='1.0' encoding='UTF-8'?> <XMLData>
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.