Why are you using onclick? onclick
executes javascript code.
Just link to the file
<a href="https://stackoverflow.com/questions/12374789/myscript.php">Say Hello</a>
If you must use javascript, you have to redirect to that page using something like window.location
solved Launch a php script without form