Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Basic Members Page

    Ok, so I have a login system, however I would like to make it so only users can view certain pages...soo if anyone can help me with a script that does the following.

    If session is set the user gets to see the page, else it echos please login

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by fus10n View Post
    Ok, so I have a login system, however I would like to make it so only users can view certain pages...soo if anyone can help me with a script that does the following.

    If session is set the user gets to see the page, else it echos please login
    That's pretty much the exact pseudocode right there. If you've already made/have the login system, you should be able to do that bit with ease.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    fus10n (01-30-2012)

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I am sorry if im being a bother but I do not quite understand. Below is one of the pages I would like to protect for members only. Please show me how I would integrate. (session set variable is "num")

    PHP Code:
    <?php 
    session_start
    (); 
    include(
    "conx.php"); 
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Web Design </title>
    <meta name="keywords" content="free css templates, web design, 2-column, html css" />
    <meta name="description" content="Web Design is a 2-column website template (HTML/CSS) provided by templatemo.com" />
    <link href="templatemo_style.css" rel="stylesheet" type="text/css" />
    <!--////// CHOOSE ONE OF THE 3 PIROBOX STYLES  \\\\\\\-->
    <link href="css_pirobox/white/style.css" media="screen" title="shadow" rel="stylesheet" type="text/css" />
    <!--<link href="css_pirobox/white/style.css" media="screen" title="white" rel="stylesheet" type="text/css" />
    <link href="css_pirobox/black/style.css" media="screen" title="black" rel="stylesheet" type="text/css" />-->
    <!--////// END  \\\\\\\-->

    <!--////// INCLUDE THE JS AND PIROBOX OPTION IN YOUR HEADER  \\\\\\\-->
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/piroBox.1_2.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $().piroBox({
                my_speed: 600, //animation speed
                bg_alpha: 0.5, //background opacity
                radius: 4, //caption rounded corner
                scrollImage : false, // true == image follows the page, false == image remains in the same open position
                pirobox_next : 'piro_next', // Nav buttons -> piro_next == inside piroBox , piro_next_out == outside piroBox
                pirobox_prev : 'piro_prev',// Nav buttons -> piro_prev == inside piroBox , piro_prev_out == outside piroBox
                close_all : '.piro_close',// add class .piro_overlay(with comma)if you want overlay click close piroBox
                slideShow : 'slideshow', // just delete slideshow between '' if you don't want it.
                slideSpeed : 4 //slideshow duration in seconds(3 to 6 Recommended)
        });
    });
    </script>
    <!--////// END  \\\\\\\-->
    <script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>

    </head>
    <body>

    <div id="templatemo_body_wrapper">
    <div id="templatemo_wrapper">

        <div id="tempaltemo_header">
            <span id="header_icon"></span>
            <div id="header_content">
                <div id="site_title">
    <a href="http://www.templatemo.com" target="_parent"><img src="images/ftt.png" alt="LOGO"  /></a></div>
                <p>This is a CSS , javascript , jquery , html website layout by arzim zakariya .  Feel free to edit and apply for your websites. Duis vitae velit sed dui malesuad mollis aliquet ligula.</p>
              <a href="#" class="detail float_r">Detail</a>
            </div>
        </div> <!-- end of header -->
        
        <div id="templatemo_main_top"></div>
        <div id="templatemo_main"><span id="main_top"></span><span id="main_bottom"></span>
            
            <div id="templatemo_sidebar">
            
         <div id="templatemo_menu">
                    <ul>
                        <li><a href="index.php" target="_parent" >Home </a></li>
                        <li><a href="seo.php" target="_parent" class="current"  >SEO</a></li>
                         <li><a href="ppc.php" target="_parent"  > PPC </a></li>
                          <li><a href="email.php" target="_parent"   >Email Marketing </a></li>
                           <li><a href="sn.php" target="_parent"  >Social Network</a></li>
                            <li><a href="mod.php" target="_parent" >Account Settings </a></li>

                       
                        
                   </ul>        
         </div> <!-- end of templatemo_menu -->
            
                <?php 
                
    if (isset($_SESSION['num']))
                {
                include(
    'log_m.php');    
                }
                else
                {
                include(
    'log_v.php');    
                }
                
                
                
    ?>
                
                <div class="sidebar_box">
                    <div class="sb_title">Latest Updates</div>
                    <div class="sb_content">
                    
                        <div class="sb_news_box">
                            <a href="#">Maecenas adipiscing elem sum ipsum.</a>
                            <span>25 September 2048</span>                    
                        </div>
                        
                        <div class="sb_news_box">
                            <a href="#">Aser ecenas adipiscing de lorem ipsum.</a>
                            <span>18 September 2048</span>                    
                        </div>
                            
                        <a href="#"><strong>View All</strong></a>
                   </div>
                   
                  <div class="sb_bottom"></div>  
                            
                </div>
                
                <center>
                  &nbsp;&nbsp;&nbsp;
            </center>
                
                <div class="cleaner"></div>
            </div> <!-- end of sidebar -->
            
        <div id="templatemo_content">
                
            <div class="content_box">
                     <h2>SEO </h2>

                  
                  
        </div>
        </div>
            
            <div class="cleaner"></div>    
        </div>
        
        <div id="templatemo_main_bottom">
        </div>

    </div> <!-- end of wrapper -->
    </div>



     <script language="JavaScript">
    // Code for validating the form

    // for details
    var frmvalidator  = new Validator("fr");
     
    frmvalidator.addValidation("nom","req","Please provide your email"); 
    frmvalidator.addValidation("nom","email","Please enter a valid email address"); 

                </script>




    <div id="templatemo_footer_wrapper">
        <div id="templatemo_footer">
            Copyright © 2048 <a href="#">Your Company Name</a> | by arzim zakariya
            
        </div>
    </div>

    </body>
    </html>

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    PHP Code:
    if (isset($_SESSION['num'])) 
                { 
                include(
    'log_m.php');     
                } 
                else 
                { 
                include(
    'log_v.php');     
                } 
    Is that not what you want? That's already in your file :S
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #5
    New Coder
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Yea, that is just for a menu...I would like it for the entire page. I tried doing it with the echo function but i keep getting errors. I think is is because I have html in there....so it possible to do a if/then statement in php to the effect of the following:

    If session is set echo "please login" else do nothing

  • #6
    New Coder
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts
    If session is not set echo "please login" else do nothing***

  • #7
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    You're mixing html and PHP which is always bad practise. You should generate your results with PHP, THEN fill out the HTML. HTML is output, PHP is processing - process before outputting. That way, you can have redirect's using the header() function, for example.

    You have your login check already, so just use that and rethink your logic. Just now, you'll have to have multiple checks for your num session variable whereas refactoring your logic to a templating method will mean only one check.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Tags for this Thread

    Posting Permissions

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