Jump to content

[SOLVED] Running this function without a form


unknown101

Recommended Posts

Hi guys, im using an ID3 class which extracts data from .mp3s.

 

Everything works but fine I want to make one further change.  I have added a upload part at the start of the script which copies the file to a given directory and I then went to the script to scan that directory automatically when that file is uploaded, rather than having to press 2 seperate buttons.

 

Currently I have to upload then hit another button to run the scan function.

 

The form which scans the directory looks like below:

 

echo '<hr><form action="'.FixTextFields($_SERVER['PHP_SELF']).'">';

echo '<b>Warning:</b> Scanning a new directory will erase all previous entries in the database!<br>';

echo 'Directory: <input type="text" name="scan" size="50" value="'.FixTextFields($text).'"> ';

echo '<input type="submit" value="Go" onClick="return confirm(\'Are you sure you want to erase all entries in the database and start scanning again?\');">';

echo '</form>';

 

The $text variable is a static var which has alrdy been set so I dont need the above within a form, i just need it to run when an upload is carried out.  (So I can just set the action of the upload form to run the whole script).

 

How can i modify the above to just run those functions without the initialisation of user pressing the button?

 

Thanks in advance

Link to comment
Share on other sites

Well, you could use some javascript to submit the form once the page has loaded, but that seems a bit stupid. You need to address this with the section of code which is executed when the form has been submitted - basically remove the check to see if the form has been submitted, then instead to taking the values from the forms, define them with the values you want.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.