juliusbenson / republickey

blockchain-based voting system
GNU General Public License v3.0
4 stars 3 forks source link

php & sql #4

Open juliusbenson opened 8 years ago

juliusbenson commented 8 years ago

Julius is signed up for this one. Get data back from the database and give it to some javascript. Suggested reading:

http://php.net/manual/en/tutorial.php

juliusbenson commented 8 years ago

Figured out how to connect to a database with php. In light of my new knowledge, I've got a couple ideas for a slightly revised software architecture; we might only really need a single php file, since it can contain html and javascript within the php file.

Possible new (simplified) control flow:

  1. user visits landing page (a single php file containing the javascript)
  2. on page load, js uses web3 lib to ask Mist wallet to request call to contract
  3. when js gets a hash back from the contract, have it trigger a "POST" event, passing the hash as an argument
  4. php grabs that hash, queries the MySQL database for it during the POST, gets the body of the corresponding proposal, and passes it to the javascript
  5. once the post is finished, the js fires an event that hashes the returned body and compares it to the hash returned by the contract. If they match, it pastes the body up on the page.