0

I just wanted to say I got all my information from this document for the most part. Making modifications as I learn. https://developers.google.com/maps/documentation/javascript/mysql-to-maps

Now I echo'd my information from sql database.. and read the file as a myfile.php.. Problem is.. if I go to www.mywebsite.com/myfile.php.. I can see all the results of my sql database.

How do I hide this information from view, but can call upon it?

PowerThree
  • 13
  • 5
  • There are a lot of options. I would say this is an opinionated question. ... Be that as it may, what do you mean by `but can call upon it?` ... Do you have a second script that will then handle the `echo`'d results? – GetSet Apr 16 '20 at 03:56
  • myfile2.php will access myfile.php in this case. but myfile.php is acting or echoing the XML results.. but as i said. if i access myfile.php it shows the echo XML results. Im trying to hide this from users directing themselves to that file.. and only have it shown if accessed when needed. – PowerThree Apr 16 '20 at 04:08
  • Have you considered getting rid of myfile.php and doing all your db stuff from myfile2.php? – GetSet Apr 16 '20 at 04:22
  • Have `myfile.php` check the [referrer URL](https://stackoverflow.com/questions/16374704/php-how-to-get-referrer-url) and only return data if it is the correct referrer. This is no guarantee that somebody won't fake the referring URL, but it will prevent the casual surfer from getting your data. – kmoser Apr 16 '20 at 05:28
  • I myfile.php is just supposed to fetch the DB results, then you should put that code into a function, and have it return the results from the function (as a string, maybe), instead of echoing them directly. Then myfile2.php can `include` myfile.php in its script, and call your function whenever it needs to read the results. Then you can echo them from myfile2.php whenever it's needed. And that way, if someone accesses myfile.php directly, the function will not have been called so the results will not echo. Sounds like you need to learn about functions, and object-oriented programming too. – ADyson Apr 16 '20 at 07:06
  • If you guys click the link i provided you. It gives the code im using basically. In summary.. the myfile.php that has the echo'd results is being used in a jquery function like so.. downloadUrl('myfile.php', function(data) { & allso true enough "GetSet", might just do that – PowerThree Apr 16 '20 at 12:58
  • https://stackoverflow.com/questions/21248728/inserting-mysql-results-from-php-into-javascript-array -> thanks man, this is waaaay more efficient and properly ethical lol dont know why google shows the XML file creating over this method? – PowerThree Apr 16 '20 at 13:20

0 Answers0