SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to do the logout pop up window

    hello everybody,
    i have a question and i hope somebody can help me.
    PHP Code:
    session_start();
    :
    :
    :
    :
    if(isset(
    $_POST['Submit']))
        {
          echo 
    '<div align="center"><span class="text"> Goodbye  ' .$_SESSION['logname'].'</span><div>';
          
    session_unset();
          
    session_destroy();
          echo 
    "<br>You have logged out successfully.";
          
        } 
    How to do the pop up window that says ARE YOU SURE YOU WANT TO LOGOUT? after clicking the LOGOUT button.
    Thank you.

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    In home!
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using JavaScript. When the user click on the link or button to logout, you have to call the onclick event and use the following JS function:

    Code:
    function deleteask(){
      if (confirm('Are you sure you want to logout?')){
        return true;
      }else{
        return false;
      }
    }
    So, your link code should be something like this:

    Code:
    <a href="logout.php" onclick="return deleteask();">Logout</a>
    That will ask you if you really want to logout, if YES, then you will go to logout.php, else, nothing will happen.
    Takitei
    FAQtion.com - Get answers to your development FAQs now!

  3. #3
    SitePoint Member celinab's Avatar
    Join Date
    Dec 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first you have to know a bit about the javascript.

    the trick is to have an event on the submit button in the html: something like "onclick=<javascript function>"

    and this javascript function has the code to ask permission

    try to grab any page that u know with this kind of behaviour and then click to see the source and study their javascript

    good luck!

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Takitei
    Code:
    function deleteask(){
      if (confirm('Are you sure you want to logout?')){
        return true;
      }else{
        return false;
      }
    }
    Where exactly am I supposed to put the function codes?

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi,
    The above code goes in your head section in javascript tags
    Code:
    <script language="Javascript">
    
    function deleteask(){
      if (confirm('Are you sure you want to logout?')){
        return true;
      }else{
        return false;
      }
    }
    </script>
    and the link as
    Code:
    <a href="logout.php" onclick="return deleteask();">Logout</a>
    Spike

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everyone!
    I got it working now. Thank you so much for all the help. I really appreciate it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •