Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,

Hopefully this is possible? Basically i am making a awesome little script maker. Anyways i have a HTML page with questions, the questions can be answered by filling out the html5/css3 coded <input></input> areas. Now here is where i am stuck, when they answer the questions and click on "Open" it redirects them to a page with their answers, displayed and ordered the way i want it to.

Now the question is, how can i then make it so instead of just viewing their <input></input> answers from using a "Open" button, which works fine, how can they actually download the answers?

I have tried making a PHP script that is executed when they click on a "Download" button for example:
PHP
<input type="button" name="downloadtest" value="Download"  önclick="location.href='downloadit.php';" >


Which i have managed so that, if accessed they will be prompted to download the file. Here is an example php of what i am using:
PHP
<?php
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="burgostest.html"');
// Output file contents here
echo "//////////////////////////////////////////////////// \r\n";
echo "// © BURGO855's ONLINE TESTTTTTTTTTTTTTTTTTTTTT © // \r\n";
echo "//////////////////////////////////////////////////// \r\n";
echo " \r\n";
echo "Special TEST \r\n";
echo " \r\n";
echo "//////////////////////////////////////////////////// \r\n";
echo "// TEST:                                         // \r\n";
echo "//////////////////////////////////////////////////// \r\n";
echo " \r\n";
echo "My name is "+myname" \r\n";
echo "I: ". $_GET['dodont']. "Don't like food \r\n";
?>


The issue is that it fails to grab the "dodont" input answer($_GET['dodont']) from the html page. So i am trying to work out a way around this. It would save me time if i can set up the "Download" button to simply use the "Open" php file and basically copy the answers from this page and give them a download link to it, i really don't know how to make this possible but i am sure their is a way to do this? Maybe even if i have to embed the php script into the html and set up the download button to just use it that way? I'm guessing it is not working because the $_GET is trying to collect data/answers from a separate html/php page? Is their a way to maybe do this in JS instead maybe? I just need an example and i should be good.

I have altered the text and button names and php names as this is a private thing i am working on, i also understand that the $_GET method is dodgy and unsecure but that is ok because the answers and stuff doesn't need to be classed or considered confidential anyways it doesn't matter if others somehow get access to it.

Anyone have any ideas?

Cheers,


-Burgo855.
Posted
Comments
Killzone DeathMan 23-Jan-14 4:40am    
<input type="button" name="downloadtest" value="Download" önclick="location.href='downloadit.php?dodont=hello';" >

Then it will apear: "I: helloDon't like food \r\n"

I dont understand much the question..
burgo855 23-Jan-14 22:37pm    
Yeah, i'm not worried about the format, i can sort that out. The issue is its not grabbing the "+myname" from the html input, instead it just displays the +myname.

So i figure their must be a way to read the input answers and display them in a file which is downloadable?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900