Hi, I have a PHP page which consists of an upload form. On the same page I have a function that does the uploading. How can I trigger the function when the form is submitted? Can the form's action parameter be the name of the function on the same page? Thanks!
Let me see if I understand this...you want a function to run when the form is submitted. Your submit button. Is probably something like this. <input name="submit" value="Search" type="submit"> Code (markup): In your php form have this. <?php if (isset($_POST['submit'])) { function(); } ?> Code (markup): granted you'll want to do a bit more than that so people can't run the function without submitting the form by some carefully crafted XSS attack. Have fun.
And thanks for the reply! That does what I need it to do but now you've got me worried about security
Have some checks on the data you expect to come in with the form and make sure it is present and valid before running hte function. If the function is harmless, don't worry. Just try to think how it could be manipulated to do something wrong, and block it. Enjoy.