Jump to content

thank you page to redirect to different urls


andycharrington

Recommended Posts

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

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

<?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.........

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.........

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

 

 

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.