graham23s
07-23-2007, 10:15 PM
Hi Guys,
i currently use a basic link of text so users can down files like so:
<a href="download.php?id='.$id.'"><font color="red" size="5"> '.$file_name.' </font>
but i was wanting to make it an actual button i have tried this below but no joy
<form action="download.php?id='.$id.'"><input type="submit" value="Download"></form>
can anyone give me some advice on how to do it correctly.
thanks guys
Graham
_Aerospace_Eng_
07-23-2007, 10:22 PM
Can I ask why you want this a button?
<form action="download.php?id='.$id.'"><input type="submit" value="Download"></form>
graham23s
07-23-2007, 10:26 PM
Hi,
well SOME people don't know how to use the link believe it or not lol if the button is staring them in the face there no 2 ways about it.
Graham
ole90
07-23-2007, 10:28 PM
<?php
echo"<form action='download.php?id='{$id}'><input type='submit' value='Download'></form>";
?>
That should fix it =X
CFMaBiSmAd
07-23-2007, 11:01 PM
graham23s, your <form action="download.php?id='.$id.'">... will work if you add a method="post" to the <form ... tag. The default method is GET when no method is specified and the form will overwrite your ?id= parameter.
Short version - the only way to have a GET parameter in the action="..." is if you specify method="post".
graham23s
07-23-2007, 11:07 PM
Hi Guys,
when i do this:
echo "<form method=\"POST\" action='download.php?id='$id'><input type='submit' value='Download'></form>";
but the id is missing the bit i need lol
is that right what i have done above?
thanks guys
Graham
_Aerospace_Eng_
07-23-2007, 11:11 PM
<form action="download.php" method="get">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" value="Download">
</form>
CFMaBiSmAd
07-23-2007, 11:13 PM
Edit: I see you edited your post and put in the code. There is an extra single-quote that is stopping the output.
You would need to post your actual code that echos the <form... to the browser.
The partial code you posted in the first post in this thread has the potential of a quoting problem and if you used ole90's posted code, it has an extra single-quote that would prevent it from working.
aedrin
07-23-2007, 11:16 PM
graham23s, your <form action="download.php?id='.$id.'">... will work if you add a method="post" to the <form ... tag. The default method is GET when no method is specified and the form will overwrite your ?id= parameter.
Actually, it won't. Do a POST with a variable in the URL, you will see all values present in $_REQUEST.
There's nothing wrong with doing it that way.
_Aerospace_Eng_
07-23-2007, 11:24 PM
This would also work
echo "<form action=\"download.php?id=$id\" method=\"post\"><input type=\"submit\" value=\"Download\"></form>";
graham23s
07-23-2007, 11:31 PM
Thanks a ton guys i got it workin perfectly:)
thanks again
Graham