I want to make a button that starts my php script after I click it. So do I just make 2 separate files and have action post to the php file and then let it start? or is there a better way to do this? Possibly in one document?
Update:
Well, I basically made a script that would do a series of a loops until it's finished. So usually when I visit the page it automatically starts, so I'm making a button to start it only when I need it.
More info: Answer to one of the questions, "starting the script" as in it would only execute the script.
More info: I really don't need to pass any data from the submit form to the php script. I just want my script to run when I hit a button. I just want to know what's the best way to do this.
Having 2 files like you suggested would be the easiest solution.
For instance:
2 files solution:
index.html
script.php
Single file solution:
index.php
You could do it in one document if you had a conditional based on params sent over. Eg:
I think the best way though is to have two files.
What exactly do you mean by "starts my php script"? What kind of PHP script? One to generate an HTML response for an end-user, or one that simply performs some kind of data processing task? If you are familiar with using the tag and how it interacts with PHP, then you should only need to POST to your target PHP script using an button of type "submit". If you are not familiar with forms, take a look here.
I know this question is 5 years old, but for anybody wondering how to do this without re-rendering the main page. This solution uses the dart editor/scripting language.
You could have an
<object>
tag that contains adata
attribute. Make the<object>
1px by 1px and then use something like dart to dynamically change the<object>
'sdata
attribute which re-renders thedata
in the 1px by 1px object.HTML Script:
someScript.php:
dartScript.dart:
So long as you aren't posting any information and you are just looking to run a script, this should work just fine.
Just build the dart script using "pub Build(generate JS)" and then upload the package onto your server.
This one works for me:
index.php
This link can be helpful:
https://blogs.msdn.microsoft.com/brian_swan/2010/02/08/getting-started-with-the-sql-server-driver-for-php/