send an html array with POST method and retrieve it with $_POST

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • pipesportugal
    Second Lieutenant

    • Jul 2007
    • 130

    send an html array with POST method and retrieve it with $_POST

    Hello dear colleagues from VH forum,

    Can anyone please teach me how to send an html array with the POST method and then retrieve on the other side with the $_POST php array ?

    Thanks in advance for all the help,
    pipesportugal
  • Andy128
    Major General

    • Dec 2005
    • 2317

    #2
    Re: send an html array with POST method and retrieve it with $_POST

    What exactly are you trying to do? Are you talking about form data or something else?

    A little more info and we'll try to help you out.

    Andy
    PHP- is a blast!

    Comment

    • pipesportugal
      Second Lieutenant

      • Jul 2007
      • 130

      #3
      Re: send an html array with POST method and retrieve it with $_POST

      Hi Andy, thanks for replying,

      It's a multiple upload file routine.

      echo "<form method=POST action=upload.php enctype=multipart/form-data>";
      echo "<p><b>Files to upload:</b><br>";
      for ($j=0; $j<$number_of_uploads; $j++)
      {
      echo "<input type=file name=img[] size=50><br><br>";
      }
      echo "<input type=hidden name=submitted value=true>";
      echo "<input type=submit name=submit value=Transferir>";
      echo "</form>";


      I have tried several different $_POST sentences to retrieve this html array, but without sucess,

      Do You think You can help?
      pipes

      Comment

      • Andy128
        Major General

        • Dec 2005
        • 2317

        #4
        Re: send an html array with POST method and retrieve it with $_POST

        This is only part of a script and if you are going to upload stuff- I would suggest using the upload script described at the begining of the forms section.

        What are you trying to do? What is it that you want the user to upload? Pictures only? Text or Doc files? Music? There are a multiple of things an upload file needs to do such as store upload files in a temporary variable and then check for file type, size and then finally place them in a directory.

        Hope that helps-

        Andy
        PHP- is a blast!

        Comment

        • Watdaflip
          Major General

          • Sep 2005
          • 2116

          #5
          Re: send an html array with POST method and retrieve it with $_POST

          First of all, you should really format the html correct, and encase every attribute in "". If you don't want to do something like

          echo "<input type=\"text\" value=\"whatever\" />";

          you can do

          echo '<input type="text" value="whatever" />';


          Now for the array question:

          You still retrieve it like a normal variable..

          $img= $_POST['img'];

          But since this is an upload your going to use the file a little differently. When you upload a file like you are you use the $_FILES superglobal array to retrieve all of the data about it.

          The $_FILES array is a multi-dimensional array, the first dimension is the "name" used in the html form, the second dimension are the different keys for the different information of the files, finally by the key to identify the upload number.

          So if you were to loop through the filenames of each of the upload files and output them, it would look something like

          $count = count($_FILES['img']);
          for($i=0; $i < $count; $i++)
          {
          echo $_FILES['img']['filename'][$i]."<br />";
          }

          If you want a list of the different file informations you can retrieve from the array check the documentation on php.net

          PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

          Register/Login Script
          Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #6
            Re: send an html array with POST method and retrieve it with $_POST

            Why don't you use ABVFP ? It will upload automatically any and as many files you like.
            Also, if you open the file dbts_abvfp from ABVFP, you will see the routine that takes care of the file processing. You can then modify it to suit your needs. there is also another routine that will attach the files to the email that is sent to you.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment

            • pipesportugal
              Second Lieutenant

              • Jul 2007
              • 130

              #7
              Re: send an html array with POST method and retrieve it with $_POST

              Hello Andy,

              Thanks for replying. I want You to know that it has been an important information for me. I used it !

              I didn't reply before because I have been testing everything to check it would work and efectively it does.
              So, I want to thank You for the help.

              Regarding the part of the:
              echo "<input type=\"text\" value=\"whatever\" />";
              it does work as:
              echo "<input type=text value=whatever>"; with no " ".
              please test it.

              Regarding naval's suggestion, I will do so, I will test the ABVFP soon. At the moment there is nothing I can say about it as I don't know this piece of software.

              Thanks guys,
              pipesportugal

              Comment

              • Andy128
                Major General

                • Dec 2005
                • 2317

                #8
                Re: send an html array with POST method and retrieve it with $_POST

                It may work.. but it is not proper. I doubt that it would work in Firefox browser as it is picky about proper coding.

                Andy
                PHP- is a blast!

                Comment

                • navaldesign
                  General & Forum Moderator

                  • Oct 2005
                  • 12080

                  #9
                  Re: send an html array with POST method and retrieve it with $_POST

                  Pipes,

                  the uploading routine of ABVFP and the one of the upload file tutorial are the same as structure, the only difference being that ABVFP will loop through the $_FILES superglobal to see how many files have been uploaded and will take care of uploading all of them.

                  The reason why i say use ABVFP is because it works in the background, ir doesn't have any visual part, so it can be used by whichever site to process the form input. And, since it is actually installed by more than 3000 users, it has been thoroughly tested.
                  Navaldesign
                  Logger Lite: Low Cost, Customizable, multifeatured Login script
                  Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                  DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                  Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                  Comment

                  Working...
                  X