aebstract
-
Posts
1,105 -
Joined
-
Last visited
Posts posted by aebstract
-
-
\n will put a new line in the code, not in the actual output. You'll have to use something like <br /> to do that.
-
I'd like to keep the main site as berryequipment.net though, that's the only problem :/ The hosting is through OLM. The browser I was using was firefox, and I was closing the entire browser. I think as long as it will kill the session in a reasonable amount of time then it will be okay.
-
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?
-
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?
-
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.
-
-
Yeah .htaccess goes in that other forum, but I figured there would be a solution to be gotten here. Was just showing how I was attempting it so far. Is there an easy way to kill a cookie or session when browser is closed?
-
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 :/
-
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 :/
-
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.
-
You should probably be using an array, every form field they add, add it to the array. Then you can just count how many items are in your array and use the information in any way you need it.
-
Whys it say your current page is 3?
-
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?
-
Hmm, is there a way to tell if the page you landed on was because you were directed by the header function?
-
for ($i = 1; $i <= 10; $i++) {
echo $i;
}
-
err... so I thought this was somehow affecting the header() instead of me having to do header_()... This defeats the whole purpose of doing this. If I was to do that, I might as well just set a session there too. It was to save me from going through and finding every spot that header was needing to be used.
-
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..
-
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.
-
I placed session_start() at the top of both my login page and my functions page and doesn't give me anything except for:
Notice: Undefined index: last_page in /home/virtual/site21/fst/var/www/html/performance/login.php on line 14
-
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?
-
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
-
session_start() is the first line in my index page so it should be included in to every other page as well, as first thing. I set the variable and then try and call it on the next page. Hence it being a variable to see the past page. =/
-
-
Whenever I try and echo that session variable out it says:
Notice: Undefined index: last_page in /home/virtual/site21/fst/var/www/html/performance/login.php on line 13
[SOLVED] echo and newline
in PHP Coding Help
Posted
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:
Really just need to move your ; to the end of the line.