1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP Using a PHP Function within a HTML FORM?

Discussion in 'Web Development' started by smartlipo, Jun 10, 2009.

  1. smartlipo

    smartlipo New Member

    I am trying to launch a PHP Function from a FORM;


    Currently I am running the Action as a seperate PHP page - like below;

    <form enctype="multipart/form-data" action="uploadCSV.php" method="POST">
    Please choose a file: <input name="uploaded" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>

    But I am having difficulty returning a Success or Failure back to this PHP page - can you call a PHP function in the "action=" instead of calling a new PHP page?

    Thanks for any help,
     
  2. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    You might be misunder standing php.

    When someone visits your PHP webpage, your web server processes the PHP code. It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to your visitor's web browser.

    In your case a form - the viewer fills out. (File 1)
    The information is sent to a php file residing on the server, which processes the information. (File 2)
    If all goes well the file returns Success if not Failure. (File 3 dispayed in browser, generated by File 2)

    Your declaration
    Code:
    ="[COLOR=red]multipart/form-data[/COLOR]" action="
    Set this scenario up.

    My guess would be there is a problem with the php file on your server in proccessing the input, therfore no output.

    There are several php commands which if coded in a page return output, as they are processed on the server side, but this not your case.
     
  3. bmcoll3278

    bmcoll3278 New Member

    Your form looks ok here is a free cgi script to do the upload. be sure the file permision is set to 755 or 777 for the folder you want to upload to and this script should work for you.
     
  4. bmcoll3278

    bmcoll3278 New Member

    the file

    sorry I messed up attaching the file
     

    Attached Files: