Jump to content

Password Protect Excel Files with PHP when Exporting from Mysql


rxbanditboy1112

Recommended Posts

The end of my code is below. I am wondering if it is possible to export a file from mysql with php and password protect it. Also I would probably need some sort of encryption with the password and then the password would need to be readable in c#. I know there are compatible encryption formats between .net and php. The main issue here is how to password protect a file. Is it possible in the below format?

 

Also I used .lw as my file extension as opposed to .xls. Trying to black box this as much as possible and not allow others to use the excel file without my windows program. Also Read Only is not a solution. I want to be able to read and write to the file later with a password.

 

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file_name.lw");
header("Pragma: no-cache");
header("Expires: 0");
print “$headern$data";

 

Link to comment
Share on other sites

Well I know I could do that, but I am trying to make this available to every user on the website. Here is an example, not the exact reason I am creating things this way. Let us say that we had a database of products. Any user could populate this database. Let us also say that each of these users has their own physical real life store. When someone buys an item is added to an orders database. Now either for accounting purposes or other let us also say that this user would like a file describing transaction history in a database like format. I would like to however not let them use Excel to open this file, but rather a windows program I created. I am trying to not allow people to manipulate fields and really try to control which entries are being edited. Also I am trying to automate other things with my windows program.

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.