Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In home page (http://mysite.com/) Running in one separate page.
when click the login button from(http://mysite.com/) this page, it will be redirect to another page.
I want to do the following below:
Before login, on the home page the chat function will be offline..
After login the other page the chat function will be online on home page.
How do I link these two pages?
Make sure to use session_start(); at top of pages.
And make sure that when they log in, you set $_SESSION['loggedin'] == TRUE; and then unset the session var on log out.
if ($_SESSION['loggedin'] == TRUE){
//include chatbox code or whatever it is
}else{
//don't add an else if you don't want anything if not logged in, but if you do, code away here
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a form with an add user button. If the user is added, the page should redirect to another page which would allow you to edit that user.
What I currently do is:
if ($user_added) {
<META HTTP-EQUIV=refresh CONTENT='0;
URL=<php echo $root. "Path1/path2/path3/userEdit.php?ID=".$newUser->GetID(); ?>'>
NOTE: ID is not something you can switch to easily, its a different more complicated number that i generate randomly whenever I add users, for the sake of the question i kept it simple.
UPDATE: This changes the page to the userEdit page but it does not load the data from the new user.
You are mixing html and php. PHP redirects can be done with a header BEFORE the page loads like so:
<?php header('Location: http://mywebsite.com/index.php'); ?>
But again this only works if the content has not yet been sent.
Also:
URL=<php echo $root. "Path1/path2/path3/userEdit.php?ID=".$newUser->GetID(); ?>'>
This is also insecure because any user can access any user's page simply by changing the url.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I prevent someone that didn't login into a page (control panel) and posting something?
I am using PHP and mysql for the login.
I assume you mean from posting something rather than and posting something. The simple explanation is that on any page that requires authorization, you need to check whether the current user is authorized. The simplest way to do this with a secure cookie and is built into PHP via the Session module.
On the login page you would have something like:
if (log_user_in($username, $password)) {
$_SESSION['authorized'] = true;
}
On pages requiring authorization, you would have a check like:
session_start();
if (!isset($_SESSION['authorized']) || !$_SESSION['authorized']) {
// redirect user away
}
Mechanisms for handling the actual logging in and modularizing the session handling/gatekeeping have been done to death and are baked into most CMS or frameworks. If you are using a CMS or framework, you should look into the specifics of authorization/authentication for it which will probably abstract a lot of what I've told you.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
If users use the registration form to register, by going directly to the registration page , then they receive an e-mail with an activation link, and when they click on it, the index page of the logged-in section is loaded. This works fine.
But in the case where the (non-registered) user goes to the registration page by clicking a link to a restricted page, the e-mail activation link redirects to here.
Because of that additional http://www.studyhood.com inserted at the beginning of the URL, the browser returns an error message.
Finally, if the user logs in (not registers) after clicking on the link to the restricted page, everything is again fine, since she is taken to translation_second.php without any problem.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a custom page in Opencart. In this page I am using PHP and Javascript based text editor. Now I need to check if user is logged in so that some more options are displayed. I had searched on Google but I did't find anything.
In Your controller (of that custom page) You can do this:
if($this->customer->isLogged()) {
echo "Customer is logged in and his ID is " . $this->customer->isLogged();
} else {
echo "Customer is not logged in";
}
This assumes that the custom page is within frontend and by user You actually mean customer (this assumption was done just because in backend every user has to be logged in prior to display any page).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how do I force a user to go back twice on a mobile web page using PHP or jAVASCRIPT without the user clicking any link or button.
something like using history.back() without a user having to click on anything
In javascript
function goBackTwice()
{
window.history.go(-2)
}
You may want to look into https://github.com/browserstate/history.js/ for a more robust client side solution.