andycharrington Posted February 14, 2008 Share Posted February 14, 2008 hello all, I have a form that is being duplicated on lots of pages within my website. this form sublits feedback on a song by a band and after giving feedback the user needs to be taken to a page where they can download the song they are reviewing. Does that make sense??!! So basiacally i want to make the "thankyou page" mysite.com/thankyou.php and that page needs to contain a code that will direct them to the thank you page of the subfolder that the form was in. Each duplication of the form will be in its own subfolder (mysite.com/band1, mysite.com/band2 etc) and within those subfolders will be the thank you page that allows the user to sownload the song they have just been reviewing. I could just alter the code for each form but there are hundereds (litteraly) of bands and this could become quite tiresome let alone time consuming. Can anyone help me with a relevant code or another way of doing this please? Thank you in advance, Andy Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/ Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 Has anyone got any ideas????? Could really do with a hand with this. Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467519 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 Come on. Someone must have some sort of idea how to do this!!?? Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467546 Share on other sites More sharing options...
redarrow Posted February 15, 2008 Share Posted February 15, 2008 when the user has daownloaded the song redirect them to a thank you page that it......... or thank the user while the song is downloading Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467549 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 no you see thats the problem. The user needs to be redirected to the thankyou page where they can download the song. I couldn't care less about thanking them. The "thankyou page" is where the song will be available for download. Does that make sense? Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467554 Share on other sites More sharing options...
redarrow Posted February 15, 2008 Share Posted February 15, 2008 so you want this.... if a user fill in a feedback form you want to redirect to a page were a music file is downloaded from the feedback form they commented on... correct.... so all you need to do is add some code to the url telling the url what the name off the band is in assoccation with the music file needed to be downloaded....... then use a $_GET to get the file.mp3 needed force download you need.... Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467556 Share on other sites More sharing options...
redarrow Posted February 15, 2008 Share Posted February 15, 2008 <?php //database connection // select statement with the users id selecting his/her song <form method="post" action="".$_SERVER['PHP_SELF]."?download=go"> <textarea name="feedback" rows="25%" cols="25%">please write your feedback here!</textarea> <input type="submit" name="submit" vlaue="submit feedback"> </form> if($_GET['download']==go){ // update database // redirect to file_download.php?mp3id=$mp3id } //} while loop ends here... //on page file_download.php <?php // force to download a file // ex, ( [url=http://localhost/php/download.php?file=C:/Apache]http://localhost/php/download.php?file=C:/Apache[/url] Group/Apache2/hongkong.php ) // hope this can save your time :-) $file = $_REQUEST['mp3id']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); @readfile($file); ?> an example it all there mate what it all about here i go there are written errors sort them there easy the concept is here...... 1. a user fill in a feedback form.... 2. the form is posted to it self with a ?download=go 3.we get the the download=go with a $_GET['go'] the database for the feed back is then inserted. 4.then were redirected to a page caled file_downlaod with the mp3 id then.. 5. we use the mp3 id to force the download with the code provided...... that it mate......... Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467568 Share on other sites More sharing options...
cyrixware Posted February 15, 2008 Share Posted February 15, 2008 Or you can use the javascript in your codes something like this... <script language="JavaScript"> alert("Thank you for..... "); win= window.open('filename.php','self') </script> You can include this in your code... or just simply use redirect.... Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467582 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 Thanks so much. we're making progress! However its not quite what i'm looking for as this would still involve changing the code for every band and there are hundereds (literally!) of them. I need a page called thankyou.php This is the page that users will be directed to after completing the feedback form. (Bear in mind that the form for every band is the same form just duplicated. So on submit every form goes to www.mysite.com/thankyou.php) The thankyou.php page needs to be able to tell where the user has come from (each band will be in its own subfolder ie mysite.com/band1/index.html (where index.html is the reaction form) mysite.com/band2/index.html etc etc) and direct them to the thanks.HTML page within the same subfolder that the form was in. So if a user reviewed band 1 they would have come from mysite.com/band1/index.html after filling in the form they will be sent to mysite.com/thankyou.PHP. The php form then needs to redirect again to mysite.com/BAND1/thanks.html.. phew! comlicated i know. Does that make more sense now? Thank you for your help so far though! Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467606 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 Am i making this clear? Am i asking to do something that's impossible? I really needs to do this somehow. If php isn't the way forward then is there another way? Maybe a bit of javascript that redirects the user to the thankyou page in THAT subfolder. ie i could make the thankyou url for the form /thankyou.html rather than http://www.mysite.com/band1/thankyou.html and it would go to that particular folders thankyou page????????? aargh! Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467622 Share on other sites More sharing options...
redarrow Posted February 15, 2008 Share Posted February 15, 2008 Did you read my post......... <?php //database connection // select statement with the users id selecting his/her song <form method="post" action="".$_SERVER['PHP_SELF]."?download=go"> <textarea name="feedback" rows="25%" cols="25%">please write your feedback here!</textarea> <input type="submit" name="submit" vlaue="submit feedback"> </form> if($_GET['download']==go){ // update database // redirect to file_download.php?mp3id=$mp3id } //} while loop ends here... //on page file_download.php <?php // force to download a file // ex, ( [url=http://localhost/php/download.php?file=C:/Apache]http://localhost/php/download.php?file=C:/Apache[/url] Group/Apache2/hongkong.php ) // hope this can save your time :-) $file = $_REQUEST['mp3id']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); @readfile($file); ?> an example it all there mate what it all about here i go there are written errors sort them there easy the concept is here...... 1. a user fill in a feedback form.... 2. the form is posted to it self with a ?download=go 3.we get the the download=go with a $_GET['go'] the database for the feed back is then inserted. 4.then were redirected to a page caled file_downlaod with the mp3 id then.. 5. we use the mp3 id to force the download with the code provided...... that it mate......... Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467623 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 yes i did mate, thanks. However i dont really understand. I have a form with jotform.com. I am going to keep this form because it allows me to export the results in a user friendly spreadsheet ideal for the bands to review their feedback. The problem is that as i am using only one form duplicated over many pages i need one page (thankyou.php) to be able to tell which subfolder the user has come from and redirect them to the thankyou.HTML page within that subfolder. I did read your post mate. Andy Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467624 Share on other sites More sharing options...
laffin Posted February 15, 2008 Share Posted February 15, 2008 U have to modify your forms. there is a method of doing what u are asking however, it relies on the browser to send the information which may be faked or a browser may not send. your best bet is to use sessions. and store the last page that a user is on. except on the thank you page, which can use this variable to return the user to the last page Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467627 Share on other sites More sharing options...
andycharrington Posted February 15, 2008 Author Share Posted February 15, 2008 Thanks but i dont understand........ Are you saying that what i want to do is possible or that i will just have to recreate the form for every band? Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467847 Share on other sites More sharing options...
laffin Posted February 15, 2008 Share Posted February 15, 2008 What I'm saying, is everything was standardized, what ya ask wudda been possible. but not everyone follows thru on the specs HTTP_REFERRER wudda been an easy way to detect where a user came from $_SERVER['HTTP_REFERRER'] However this header variable is sent by the browser, which some may not send it, and if ppl know about this, some will try faking it. So your best bet is to use SESSIONS. now if u have a standard include that u include everywhere you can set a session, of the last page the user was on and exclude it from setting this session if it's in yer thankyou.php standard.php which is included in all php pages (or just add it to another global php file that is included to all yer scripts) [code] <?php session_start(); if(!PROCESSING) $_SESSION['lastpage']=$_SERVER['REQUEST_URI']; ?> thankyou.php <?php define('PROCESSING',1); include('standard.php') if(empty($_SESSION['lastpage'])) die('Can not access this page directly"); $baseurl=basedir($_SESSION['lastpage']); ?> <html> <head> <title>Thanks</title> <META http-equiv="refresh" content="5;URL=<?=$baseurl?>"></head> <body bgcolor="#ffffff"> <center>Thanks for using our system, you will now be sent from whence ya came</center> </body> </html> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/91170-thank-you-page-to-redirect-to-different-urls/#findComment-467892 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.