Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Posts posted by aebstract

  1. Yeah you're putting the br outside of your ;

    You would either have to close your php tags ?> <br /> <?php which I don't think is that practical, personally.

    Or something like neil suggested:

     

    for ($i = 0;$i < 10; $i++){
        echo $i <br />;
        }
    

     

    Really just need to move your ; to the end of the line.

  2. Okay maybe calling it a splash page is almost incorrect, though it is technically a splash page. Like I said it is two COMPLETELY different websites. My boss was against the idea of setting up space and everything and getting another domain, wanted to keep it on the same domain name. One if for poultry processing, dealing with clients like Tyson Foods, Foster Farms, lalala. The other site is for performance racing parts which deals with performance part shops and whatnot. This is the reason for the splash, to separate them and let the user choose where they want to go. The domain berryequipment.net will be what the user goes to regardless of where they want to end up, though if they choose poultry they will be redirected to the actually "berryequipment.net" and performance will be "berryequipment.net/performance". Hopefully this makes more sense now. Anyway, the code I came back and posted does the job fine, it just isn't killing the session when the browser is closed?

  3. That's great and all, but it's two completely different sites. Which is why it is split in to two, and "splash" isnt going to be set as 'true' it is being set as either poultry or performance so that I know which site they want to view. Premiso, I close the browser and then go to the domain.net and am directed to whatever was last time chosen. Rhodesa I asked about how I could have it so when you close the browser it kills the session, and you said to set the lifetime to 0, which is why I have the ini?

  4. Okay I have this now:

     

      ini_set('session.cookie_lifetime', 0);
        session_start();
    
        if (isset($_GET["set"])){
        $_SESSION['site_choice'] = $_GET["set"];
        header("Location: http://www.berryequipment.net/");
        exit;
        }
    

     

    Then I direct the user to the correct page depending on what the session is set to. Am I using the lifetime part incorrectly? I closed the browser, waited a few moments and reopened, went to the website and was being redirected immediately as the session was still set.

  5. Not sure this is the right place, though I had this in the Apache HTTP Server section since yesterday and no hits on it. If this is the wrong place just delete it or something :/ Though, maybe theres something I can do with php :)

     

    Here is my .htaccess:

    Code:

    DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html
    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4&var4=$5  [NC,L]
    

     

     

    The only thing important at this point is the top line: DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html

     

    I have two main websites running out of one domain. domain.net and domain.net/directory

    I am needing to have it so that when you go to domain.net you get the splash screen the first time (which is why I added the /splash/index.html) but then need to be able to get out of that splash directory to the actual website. If I change my links to domain.net/index.php or domain.net/directory/index.php I don't run in to a problem. Though, I have some links throughout the websites that will reference just the main directory and not the individual .php file, so that begins to be an issue that someone may click a link and get sent to the splash screen, rather than that sites home page :/

  6. Here is my .htaccess:

    DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html
    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([[:alnum:]_]+)/$ /index.php?page=$1 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2 [NC,L]
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3 [NC,L] 
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4 [NC,L] 
    RewriteRule ^([[:alnum:]_]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/([[:alnum:]]+)/$ /index.php?page=$1&var1=$2&var2=$3&var3=$4&var4=$5  [NC,L] 
    
    

     

    The only thing important at this point is the top line: DirectoryIndex /splash/index.html /splash/index.php index.pl index.php index.html

     

    I have two main websites running out of one domain. domain.net and domain.net/directory

    I am needing to have it so that when you go to domain.net you get the splash screen the first time (which is why I added the /splash/index.html) but then need to be able to get out of that splash directory to the actual website. If I change my links to domain.net/index.php or domain.net/directory/index.php I don't run in to a problem. Though, I have some links throughout the websites that will reference just the main directory and not the individual .php file, so that begins to be an issue that someone may click a link and get sent to the splash screen, rather than that sites home page :/

  7. Once you start to get them down, they can be fairly easy and very very useful. First look here: http://us3.php.net/manual/en/function.array.php, read through till you get to user comments, that will help you out in understanding how they are setup and their form.

     

    I'm not sure I have any quick easy examples, but if you read over that page and take a stab at it, you can come ask on anything you get stuck at and we can work through it.


  8. Okay I'm basically trying what you have described premiso, which was the basic idea I had when I was trying to think of a new way to approach it. I have this for the top of my index page:

    <?php
    session_start();
    header("Cache-control: private");
    
    $lastpage = $_SESSION['last_page'];
    $_SESSION['last_page'] = $_SESSION['this_page'];
    if (isset($_GET['page'])){
    $_SESSION['this_page'] = "$_SERVER[php_SELF]?page=$_GET

    ";
    } else {
    $_SESSION['this_page'] = $_SERVER['PHP_SELF'];
    }
    

     

    Trying to simply echo the lastpage variable when I'm on my login page. Here is what happens:

     

    I'm on home page.

    Go to contact page.

    Go to login page.

     

    ---> displays: /performance/index.php?page=login

    f5-> displays: /performance/index.php?page=contact

    f5-> displays: /performance/index.php?page=login

     

    How come I have to refresh to see "contact" as the previous page, when it was in fact the previous page. It has like a "lag" on it, do you see what is causing this?

  9. inside functions.php:

    
    function header_($header, $setPage=true) {
         if ($setPage)
    header("Location: index.php?page=thisworks");
             $_SESSION['last_page'] = $_SERVER['PHP_SELF'];
    $_SESSION['count_last_page'] = 1;
         header($header);
    
         return true;
    }
    

     

     

    inside index.php:

    <?php
    session_start();
    header("Cache-control: private");
    
    require_once('functions.php');
    

     

    The functions is pulled in at the top of the index..

  10. Okay just figured out that this won't work:

     

    
    function header_($header, $setPage=true) {
         if ($setPage)
    
    header("Location: index.php?page=thisworks");
    
         return true;
    }
    

     

    I still go to page=login, whenever I use just that. Like I said before, I don't understand exactly what's going on in this so it's hard for me to really troubleshoot that function.

  11. thorpe, the function that was made earlier in this forum is the one used within functions.php which you can see is included in to index.php

     

    premiso, I understand it needs to be at the top, but the function that creates the session isn't on the login page, its in functions.php which is simple a php file of functions created. Needs to go top of that page?

     

  12. all other pages are included in to index.

     

    heres an example, products page:

    <?php
    if(!isset($_SESSION["id"]))
    {
    header("Location: index.php?page=login");
    exit;
    }
    

     

     

     

     

     

    login.php

    <?php
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    header("Cache-control: private");
    if(isset($_SESSION["id"]))
    {
    header("Location: index.php?page=myaccount");
    exit;
    }
    
    $error = "";
    
    echo "$_SESSION[last_page]";
    
    

     

     

     

    index.php

    <?php
    session_start();
    header("Cache-control: private");
    
    require_once('functions.php');
    
    $content = '';
    
    

     

     

    These are really the only bits that matter, the function is in functions.php

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.