How to display alert if user has't logged in












0















I have a package page. all users can access it. those who want to order this package must log in first. when the user hasn't logged in and they click the booking button a warning will appear. "You must log in". how can I set like that.
this is the packages
https://i.imgur.com/CSSszbo.png










share|improve this question

























  • Are you using PHP? Specify the details.

    – Shashidhara
    Jan 1 at 6:49











  • are you using ajax or direct submit page ?

    – Niklesh Raut
    Jan 1 at 6:50











  • yes I using php @Shashidhara

    – Aden
    Jan 1 at 7:03











  • I'm using ajax @C2486

    – Aden
    Jan 1 at 7:06











  • which authentication method you are using share all detail you have. ?

    – Niklesh Raut
    Jan 1 at 7:15
















0















I have a package page. all users can access it. those who want to order this package must log in first. when the user hasn't logged in and they click the booking button a warning will appear. "You must log in". how can I set like that.
this is the packages
https://i.imgur.com/CSSszbo.png










share|improve this question

























  • Are you using PHP? Specify the details.

    – Shashidhara
    Jan 1 at 6:49











  • are you using ajax or direct submit page ?

    – Niklesh Raut
    Jan 1 at 6:50











  • yes I using php @Shashidhara

    – Aden
    Jan 1 at 7:03











  • I'm using ajax @C2486

    – Aden
    Jan 1 at 7:06











  • which authentication method you are using share all detail you have. ?

    – Niklesh Raut
    Jan 1 at 7:15














0












0








0








I have a package page. all users can access it. those who want to order this package must log in first. when the user hasn't logged in and they click the booking button a warning will appear. "You must log in". how can I set like that.
this is the packages
https://i.imgur.com/CSSszbo.png










share|improve this question
















I have a package page. all users can access it. those who want to order this package must log in first. when the user hasn't logged in and they click the booking button a warning will appear. "You must log in". how can I set like that.
this is the packages
https://i.imgur.com/CSSszbo.png







php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 7:26







Aden

















asked Jan 1 at 6:47









AdenAden

64




64













  • Are you using PHP? Specify the details.

    – Shashidhara
    Jan 1 at 6:49











  • are you using ajax or direct submit page ?

    – Niklesh Raut
    Jan 1 at 6:50











  • yes I using php @Shashidhara

    – Aden
    Jan 1 at 7:03











  • I'm using ajax @C2486

    – Aden
    Jan 1 at 7:06











  • which authentication method you are using share all detail you have. ?

    – Niklesh Raut
    Jan 1 at 7:15



















  • Are you using PHP? Specify the details.

    – Shashidhara
    Jan 1 at 6:49











  • are you using ajax or direct submit page ?

    – Niklesh Raut
    Jan 1 at 6:50











  • yes I using php @Shashidhara

    – Aden
    Jan 1 at 7:03











  • I'm using ajax @C2486

    – Aden
    Jan 1 at 7:06











  • which authentication method you are using share all detail you have. ?

    – Niklesh Raut
    Jan 1 at 7:15

















Are you using PHP? Specify the details.

– Shashidhara
Jan 1 at 6:49





Are you using PHP? Specify the details.

– Shashidhara
Jan 1 at 6:49













are you using ajax or direct submit page ?

– Niklesh Raut
Jan 1 at 6:50





are you using ajax or direct submit page ?

– Niklesh Raut
Jan 1 at 6:50













yes I using php @Shashidhara

– Aden
Jan 1 at 7:03





yes I using php @Shashidhara

– Aden
Jan 1 at 7:03













I'm using ajax @C2486

– Aden
Jan 1 at 7:06





I'm using ajax @C2486

– Aden
Jan 1 at 7:06













which authentication method you are using share all detail you have. ?

– Niklesh Raut
Jan 1 at 7:15





which authentication method you are using share all detail you have. ?

– Niklesh Raut
Jan 1 at 7:15












1 Answer
1






active

oldest

votes


















0














The simplest way to do this is:



While creating links check if the user is logged in or not. If user is logged in then add url of the package, otherwise add a simple javascript code to open popup.



If you are using session then you might need to add something like this:



if (isset($_SESSION['user'])){ ?>
<a href="http://www.example.com">Booking</a><?php
}
else{ ?>
<a href="#" onclick="alert('You must log in')">Booking</a><?php
}


Also you would need to add redirection for non logged in users on the package page as well.






share|improve this answer


























  • I think this something related to authentication and then display popup

    – Niklesh Raut
    Jan 1 at 7:16











  • I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

    – Aden
    Jan 1 at 7:17











  • @Aden Updated My Answer

    – Muhammad Bilal
    Jan 1 at 7:24











  • @MuhammadBilal it solved. Thank you very much.

    – Aden
    Jan 1 at 7:37











  • Your code contains syntax errors and will cause fatal errors if run like this.

    – Qirel
    Jan 1 at 8:05











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993550%2fhow-to-display-alert-if-user-hast-logged-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The simplest way to do this is:



While creating links check if the user is logged in or not. If user is logged in then add url of the package, otherwise add a simple javascript code to open popup.



If you are using session then you might need to add something like this:



if (isset($_SESSION['user'])){ ?>
<a href="http://www.example.com">Booking</a><?php
}
else{ ?>
<a href="#" onclick="alert('You must log in')">Booking</a><?php
}


Also you would need to add redirection for non logged in users on the package page as well.






share|improve this answer


























  • I think this something related to authentication and then display popup

    – Niklesh Raut
    Jan 1 at 7:16











  • I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

    – Aden
    Jan 1 at 7:17











  • @Aden Updated My Answer

    – Muhammad Bilal
    Jan 1 at 7:24











  • @MuhammadBilal it solved. Thank you very much.

    – Aden
    Jan 1 at 7:37











  • Your code contains syntax errors and will cause fatal errors if run like this.

    – Qirel
    Jan 1 at 8:05
















0














The simplest way to do this is:



While creating links check if the user is logged in or not. If user is logged in then add url of the package, otherwise add a simple javascript code to open popup.



If you are using session then you might need to add something like this:



if (isset($_SESSION['user'])){ ?>
<a href="http://www.example.com">Booking</a><?php
}
else{ ?>
<a href="#" onclick="alert('You must log in')">Booking</a><?php
}


Also you would need to add redirection for non logged in users on the package page as well.






share|improve this answer


























  • I think this something related to authentication and then display popup

    – Niklesh Raut
    Jan 1 at 7:16











  • I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

    – Aden
    Jan 1 at 7:17











  • @Aden Updated My Answer

    – Muhammad Bilal
    Jan 1 at 7:24











  • @MuhammadBilal it solved. Thank you very much.

    – Aden
    Jan 1 at 7:37











  • Your code contains syntax errors and will cause fatal errors if run like this.

    – Qirel
    Jan 1 at 8:05














0












0








0







The simplest way to do this is:



While creating links check if the user is logged in or not. If user is logged in then add url of the package, otherwise add a simple javascript code to open popup.



If you are using session then you might need to add something like this:



if (isset($_SESSION['user'])){ ?>
<a href="http://www.example.com">Booking</a><?php
}
else{ ?>
<a href="#" onclick="alert('You must log in')">Booking</a><?php
}


Also you would need to add redirection for non logged in users on the package page as well.






share|improve this answer















The simplest way to do this is:



While creating links check if the user is logged in or not. If user is logged in then add url of the package, otherwise add a simple javascript code to open popup.



If you are using session then you might need to add something like this:



if (isset($_SESSION['user'])){ ?>
<a href="http://www.example.com">Booking</a><?php
}
else{ ?>
<a href="#" onclick="alert('You must log in')">Booking</a><?php
}


Also you would need to add redirection for non logged in users on the package page as well.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 1 at 9:00

























answered Jan 1 at 6:59









Muhammad BilalMuhammad Bilal

1,81811122




1,81811122













  • I think this something related to authentication and then display popup

    – Niklesh Raut
    Jan 1 at 7:16











  • I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

    – Aden
    Jan 1 at 7:17











  • @Aden Updated My Answer

    – Muhammad Bilal
    Jan 1 at 7:24











  • @MuhammadBilal it solved. Thank you very much.

    – Aden
    Jan 1 at 7:37











  • Your code contains syntax errors and will cause fatal errors if run like this.

    – Qirel
    Jan 1 at 8:05



















  • I think this something related to authentication and then display popup

    – Niklesh Raut
    Jan 1 at 7:16











  • I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

    – Aden
    Jan 1 at 7:17











  • @Aden Updated My Answer

    – Muhammad Bilal
    Jan 1 at 7:24











  • @MuhammadBilal it solved. Thank you very much.

    – Aden
    Jan 1 at 7:37











  • Your code contains syntax errors and will cause fatal errors if run like this.

    – Qirel
    Jan 1 at 8:05

















I think this something related to authentication and then display popup

– Niklesh Raut
Jan 1 at 7:16





I think this something related to authentication and then display popup

– Niklesh Raut
Jan 1 at 7:16













I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

– Aden
Jan 1 at 7:17





I'm sorry, I'm a newbie, I don't know how to write chek session in javascript, but I make chek session in another file. when I include 'check.php', the alert appear and user hasn't logged in can't access the package page. I want all user can access it but for book user have to log in. I'm sorry, my english is bad but I hope you understand what I say

– Aden
Jan 1 at 7:17













@Aden Updated My Answer

– Muhammad Bilal
Jan 1 at 7:24





@Aden Updated My Answer

– Muhammad Bilal
Jan 1 at 7:24













@MuhammadBilal it solved. Thank you very much.

– Aden
Jan 1 at 7:37





@MuhammadBilal it solved. Thank you very much.

– Aden
Jan 1 at 7:37













Your code contains syntax errors and will cause fatal errors if run like this.

– Qirel
Jan 1 at 8:05





Your code contains syntax errors and will cause fatal errors if run like this.

– Qirel
Jan 1 at 8:05




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993550%2fhow-to-display-alert-if-user-hast-logged-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter