countdrac Posted October 30, 2007 Share Posted October 30, 2007 hi i really am having a difficult time understanding this: i have a admin page that allows users to fill in a form this page send the form info to a preview page which previews the form on the screen on this page is another form (just a save and edit button) when they click the save it calls a javascript function which saves the file and attempts to redirect them back to the original admin page with info (which i have as a php variable) on what was just saved i need to redirect them with the name of the file which was saved! ie: admin?successfull=<?php $filename; ?> i cant find anything to do this!!! ive tried: document.goNext.action= (goNext was the name of the form) - doesnt work ive tried: header(Location:) which sent but without the variables and ive tried: location.href which did nothing if anyone can help i would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/ Share on other sites More sharing options...
toplay Posted October 30, 2007 Share Posted October 30, 2007 I'm not sure if I totally understand you, but here's a very basic example of how to redirect and pass GET values: <?php $strFilename = 'sample.txt'; $strUrl = 'http://www.example.com/admin.php?file=' . urlencode($strFilename); header('Location: ' . $strUrl); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/#findComment-381306 Share on other sites More sharing options...
trav Posted October 30, 2007 Share Posted October 30, 2007 i am a little confused as well, are you looking for a javascript event to automatically send the user to a new page once the file has been confirmed saved? ie. so when they click the save button the info is sent to the server and saved, then retrieve the file name and send to a new page. Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/#findComment-381341 Share on other sites More sharing options...
countdrac Posted October 30, 2007 Author Share Posted October 30, 2007 right exactly what you said at the end except i dont need to retrieve anything as i have the variables from the save function (auto-forward with php if possible) the redirect is itself within a redirect() javascript function. but for some reason when i try the header('Location :' .$page); it just reloads the current page (but it does the saving and stuff) just the redirect - this header command - doesnt work at all, the page im currently on just reloads - not the one i indended to go to. also i only want the redirect to excecute once the hit the save button (after which two functions are called - saveFile() and redirect() ) ive never seen the exit; command before but if thats in my code the page crashes and the the save button doesnt even appear thanks Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/#findComment-381458 Share on other sites More sharing options...
trav Posted October 30, 2007 Share Posted October 30, 2007 i am less confused but still slightly, can you post some code. one quick point though, the header('Location :' .$page); will only work if it is called before any html is displayed. I don't know how this would work calling it in a javascript function but i wouldn't expect it to work. Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/#findComment-381573 Share on other sites More sharing options...
countdrac Posted November 1, 2007 Author Share Posted November 1, 2007 hey i ended up changing a whole lotta stuff and got used a hidden form thing thanks for the help though dave Quote Link to comment https://forums.phpfreaks.com/topic/75382-solved-page-redirect-with-variables-help/#findComment-382582 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.