Tokae Posted April 27, 2012 Share Posted April 27, 2012 I have an html table that is being populated with links from a specific directory.. I would like the user to be able to click the link and if its a file they will download the file. If its a directory, I woudl like to reload the current page but this time show the contents of the directory. My main issue is that I have a session variable called 'workingdirectory' that I need to update before I reload the page. I have tried setting it and then calling Location('page.php') but I get the 'cannot change header information' error. I realized I was getting this because I had begun to call HTML code before the PHP was finished. Is there a way to just simply update the session variable, and then make the page reload when the user clicks on a link? Quote Link to comment https://forums.phpfreaks.com/topic/261729-a-simple-way-to-just-reload-a-current-page/ Share on other sites More sharing options...
requinix Posted April 27, 2012 Share Posted April 27, 2012 Simple: don't use a session variable for it. Stick in the URL. script.php?dir=foo/bar/baz Be sure to validate it before you use it blindly. Quote Link to comment https://forums.phpfreaks.com/topic/261729-a-simple-way-to-just-reload-a-current-page/#findComment-1341245 Share on other sites More sharing options...
Tokae Posted April 27, 2012 Author Share Posted April 27, 2012 Thank you, That does the job! I was hoping to use a session though so the directories were not listed in URL. Is there a way to just reload the page after setting a session variable? I am just drawing a blank and admittedly not the best with php yet I had my conditional line calling a function if a directory was found: <a href=" <?php ChangeFolder($file) ?>"> directory name here</a> <?php function ChangeFolder($file) { $_SESSION['workingfolder'] = $_SESSION['workingfolder']."/".$file; *** refresh page or reload page here*** } ?> I just cant for the life of me figure out the simple way to reload the page :/ Once again thank you though for your solution.. Quote Link to comment https://forums.phpfreaks.com/topic/261729-a-simple-way-to-just-reload-a-current-page/#findComment-1341253 Share on other sites More sharing options...
requinix Posted April 27, 2012 Share Posted April 27, 2012 Sessions are not for keeping things out of the URL. It's not what they're for. It's part of how they work and not why they work. Nothing in the URL? Then use a POSTed form. Quote Link to comment https://forums.phpfreaks.com/topic/261729-a-simple-way-to-just-reload-a-current-page/#findComment-1341261 Share on other sites More sharing options...
Tokae Posted April 27, 2012 Author Share Posted April 27, 2012 Solid copy! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/261729-a-simple-way-to-just-reload-a-current-page/#findComment-1341269 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.