xProteuSx Posted December 1, 2006 Share Posted December 1, 2006 I remember there used to be a javascript snippet that everyone used to go back one page in browser history. How do I accomplish this with PHP?? Thanks ... Quote Link to comment Share on other sites More sharing options...
fert Posted December 1, 2006 Share Posted December 1, 2006 well the best way to do it would be with javascript, because with PHP you can only use the code at the very top of your script Quote Link to comment Share on other sites More sharing options...
Fallen_angel Posted December 1, 2006 Share Posted December 1, 2006 yeah javascript is the best option for a back button [code]<a href="javascript:history.back()"><< Go Back</a>[/code]will do it Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 1, 2006 Author Share Posted December 1, 2006 Thanks, I guess I will go with javascript. Do you know of a similar bit of code where instead of history.back() I could go to another page, such as page2.html? Quote Link to comment Share on other sites More sharing options...
fert Posted December 1, 2006 Share Posted December 1, 2006 document.location="http://www.mysite.com/page.htm";will that you to another page. Quote Link to comment Share on other sites More sharing options...
Fallen_angel Posted December 1, 2006 Share Posted December 1, 2006 just to present another alternative using a standard hyperlink will do what you have asked the seccond time , the reason you need javascript for the first is because you actually need to make a query on the clients end , if however your actually telling the link to go to a specific spot on your server then you can just use somethign like bellow [code]<a href="./index2.html">text you want for link </a>[/code]personaly I use things like javascript and other client side scripting languages as little as possible . peopel have had problems with things like malware through enabling client side scripting over the years , and 80% of doccuments that tell people how to get a bit more security from their browser advise the imediate disabling of things like javascript. ( although the trend of people enabling it due to security improvements has increased it's still not to a level you can count on ) Something thats good practice to keep in mind at all times when developing for the web is usability across various platforms , settings , browsers and ofcourse the loading times . So if you can use a simple thing like a hyperlink then there is no need to be using javascript for it if however your just practicing and learnign allogn the way it's alwasy good experiance to use it as much as possible Quote Link to comment Share on other sites More sharing options...
projectshifter Posted December 1, 2006 Share Posted December 1, 2006 When I try to post what I need to it keeps saying connection reset :X Edit:Weird, it did not like the javascript I put up :(If you wanted to this with PHP, you can use GETENV('HTTP_REFERER') and use that in conjunction with either header('Location: url'); or javascript redirection. Quote Link to comment Share on other sites More sharing options...
Fallen_angel Posted December 1, 2006 Share Posted December 1, 2006 by any chance where you using a script tag ?if so thats why it didn't let it post , I had the same issue a few weeks ago , if you replace the javascript tags though you will be fine and it will post the message Quote Link to comment Share on other sites More sharing options...
projectshifter Posted December 1, 2006 Share Posted December 1, 2006 [quote author=Fallen_angel link=topic=116935.msg476800#msg476800 date=1164953541]by any chance where you using a script tag ?if so thats why it didn't let it post , I had the same issue a few weeks ago , if you replace the javascript tags though you will be fine and it will post the message [/quote]Ah, gotcha, thanks for the heads up, it was a script tag. I couldn't figure out for the life of me why on earth this was happening. I've never been too fond of SMF forums, they're a pain in the ass to mod as well. You'd think you could simply use htmlentities() and strip out the html blocks or replace the script tag and all would be well... guess not Quote Link to comment Share on other sites More sharing options...
Fallen_angel Posted December 1, 2006 Share Posted December 1, 2006 yeah I spent a good 2 hours the other week slappin myself tryign to figure out where I was goign wrong , hehe haven't used SMF before , am more of an ipb person myself however it doesn't seem to bad at all for a free alternative one day I want to write my own forums , but I have allot to learn first hehe Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 1, 2006 Author Share Posted December 1, 2006 Fallen_Angel, I could not use a simple link such as <a href="./index2.html">text you want for link </a>. The reason is a little difficult to explain but I will try ...My first page, page1.php, has a form with some variables. When you hit Submit you are taken to page2.php which processes the variables from page1.php, and has a form of its own. When you hit Submit on the second form on page2.php you are taken to page3.php which processes the variables from the form from page2.php. If there is an error in the variables received by page3.php from the form from page2.php I want a back button on page3.php so that the user can re-enter the info into page2.php. If, however, I use a simple link what happens is that the browser re-sends for page2.php from the web server, but it does not have the values from page1.php, so there are a series of errors. If, however, I use the history.back() function of javaScript the page is reloaded from cache, with variables intact.Hope I didn't make anyone dizzy ... Quote Link to comment Share on other sites More sharing options...
Fallen_angel Posted December 1, 2006 Share Posted December 1, 2006 Sorry I think there may be some confusion in what I was sugesting , my first post gave you the answer to your first questionmy seccond post was answering how you could make a link there to take you to another page besides back , I assumed that you would not need a link from a page in a form to another page ,because I would image you already defined that in the form tag itself , so all you need is a standard submit button.from the sounds of your explination you just need the back button and your standard submit buttons so please ignore my seccond post and just use whats in the first sorry I misunderstood your seccond post Quote Link to comment 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.