Page 1 of 1
***Solved*** File download using PHP
Posted: Wed May 03, 2017 6:06 am
by alex4orly
I am trying to call a PHP function from a button click... Not working
Add into the button Inside Tag : onclick="<?php echo download('memberslogin.php'); ?>"
Trying to call the function :
<?php
function download($filename)
{
.....
}
?>
Re: File download using PHP
Posted: Wed May 03, 2017 6:16 am
by Pablo
You cannot call a PHP function via JavaScript.
JavaScript runs in the browser, PHP on the server.
Re: File download using PHP
Posted: Wed May 03, 2017 11:00 am
by alex4orly
Is OnClick JavaScript?
Re: File download using PHP
Posted: Wed May 03, 2017 11:06 am
by BaconFries
Re: File download using PHP
Posted: Wed May 03, 2017 11:26 am
by BaconFries
@alex with this being said and you still need to download a file(s) the following URL describes and gives a demo/download of how to achieve this using a protected page. Maybe by downloading the demo zip it will help you to achieve even if it means you have to modify it. Note that Navaldesign is on holiday I believe so any questions you may have about this will/go unanswered till he returns.
https://www.wysiwygwebbuilder.com/forum ... 44&t=20970
Re: File download using PHP
Posted: Wed May 03, 2017 11:37 am
by Pablo
Yes, onclick is JavaScript.
Note that PHP code is not send to the browser. It is processed on the server.
Re: File download using PHP
Posted: Thu May 04, 2017 4:09 am
by alex4orly
Thanks Baconfries,
The sample project and code worked for me just fine
Cheers
Re: File download using PHP
Posted: Thu May 04, 2017 10:15 am
by BaconFries
,

Re: ***Solved*** File download using PHP
Posted: Thu May 04, 2017 12:10 pm
by alex4orly
I am missing one final step.
I need to download the data file which is in my case members.php with the 'I ' separator to an actual csv file, comma selarated..
Any suggestions?
Cheers