michael1291 Posted June 14, 2011 Share Posted June 14, 2011 I am currently working on a client login system, up to now it allows users to register and then it looks up the database and redirects them to their own are upon successful login. after they arrive there it displays their personal details and allows them to change them, now how can i redirect users based on their username for example if a normal user logs in it takes them to their area and if an admin logs in it takes them to their area. also i am wondering if it is possible to create an on/ off button by this i mean if the buttons state is on then enter value in database if its off enter a different value in database. i would like to thank you in advance and appreciate any help, michael. Quote Link to comment Share on other sites More sharing options...
redixx Posted June 14, 2011 Share Posted June 14, 2011 Sorry, I am having a hard time understanding your post. Can you try to articulate a little better? Quote Link to comment Share on other sites More sharing options...
plznty Posted June 15, 2011 Share Posted June 15, 2011 Confusing how you said it, can that be done.. yes. It sounds like (from what you have posted) that you are doing a lot of things that you are not sure are possible. I would recommend looking at PHP tutorials and MySQL tutorials in order to see what functions can be used where. Its like creative yet logical problem solving. Good luck, we are here to help you once you are on your way, hence the forum category PHP Coding Help. Quote Link to comment Share on other sites More sharing options...
savagenoob Posted June 15, 2011 Share Posted June 15, 2011 Yeah, way confusing, PHP can do everything bro. For the admin section... research $_SESSION's, store in the session if the user is an admin, put some code in your header section to look up if a user is an admin, then write some html or redirect. Quote Link to comment Share on other sites More sharing options...
michael1291 Posted June 15, 2011 Author Share Posted June 15, 2011 sorry for being confusing did not read the post before submitting it. I have worked it out, i was already using $_SESSION['member_id'] so i just wrote if the member id = to that of the admin then redirect to the admin area else redirect to the client area. Does any one know how to create a button that will send a value to the database for example if a user presses the button on it will send a value to the database and if they press it again it will then update with a different value. I' am guessing i may need to use javascript. Quote Link to comment Share on other sites More sharing options...
savagenoob Posted June 15, 2011 Share Posted June 15, 2011 If you want the button to update the database without a page action then yes, some javascript/PHP(AJAX) will do it. Quote Link to comment Share on other sites More sharing options...
redixx Posted June 15, 2011 Share Posted June 15, 2011 sorry for being confusing did not read the post before submitting it. I have worked it out, i was already using $_SESSION['member_id'] so i just wrote if the member id = to that of the admin then redirect to the admin area else redirect to the client area. Does any one know how to create a button that will send a value to the database for example if a user presses the button on it will send a value to the database and if they press it again it will then update with a different value. I' am guessing i may need to use javascript. You can easily do this with jQuery. Have a look at http://api.jquery.com/jQuery.post/ Quote Link to comment Share on other sites More sharing options...
michael1291 Posted June 15, 2011 Author Share Posted June 15, 2011 what i am trying to do " if the user turns the button off they will stop receiving information into their private members area but when they turn the button back on again they will then start receiving the information when it is available." by the way i appreciate the help and have found that you guys reply quickly compared to forums i have used in the past!!! Quote Link to comment Share on other sites More sharing options...
redixx Posted June 15, 2011 Share Posted June 15, 2011 Something on the idea of this function update() { $.post('update.php',function(data){ $('#info').html(data); }); var timeout = setTimeout('update', '1000'); } $('#button-on').click(function(){ $('#button-on').val('Turn Off'); $('#button-on').attr('id','button-off'); update(); }); $('#button-off').click(functon(){ $('#button-off').val('Turn On'); $('#button-off').attr('id','button-on'); clearTimeout(timeout); }); <div id="info"></div> <input type="button" id="button-on" value="Turn On" /> Quote Link to comment Share on other sites More sharing options...
michael1291 Posted June 15, 2011 Author Share Posted June 15, 2011 that was quick! and that is great although i cannot get it to work and if i did i still cannot get it to add a value to the database to tell t he admin that they currently have it turned on or off. (wish i outsourced this project now). Quote Link to comment Share on other sites More sharing options...
redixx Posted June 15, 2011 Share Posted June 15, 2011 Why do you need to update the database to say whether it is on or off? Once you turn it on it should keep looping until you turn it back off. Quote Link to comment Share on other sites More sharing options...
michael1291 Posted June 15, 2011 Author Share Posted June 15, 2011 So the that admin can find out who has it turned on, therefore there know who to send the information to. am i thinking in to this too much lol is there an easier way to carry out what i need to do Quote Link to comment Share on other sites More sharing options...
savagenoob Posted June 16, 2011 Share Posted June 16, 2011 How about a simple form with a checkbox that once submittied inserts "On" or "Off" in a field in the database. Just query the database and input as value of the form field to see the current setting. Quote Link to comment Share on other sites More sharing options...
michael1291 Posted June 16, 2011 Author Share Posted June 16, 2011 That is actually a great idea and that kind of makes it easy to query the database and return results for those who have it on. thanks (research time lol). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.