Results 1 to 9 of 9

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

  1. #1
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Question 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

  2. #2
    Andy128's Avatar
    Andy128 is offline Major General
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,322

    Default 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!

  3. #3
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  4. #4
    Andy128's Avatar
    Andy128 is offline Major General
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,322

    Default 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!

  5. #5
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default 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

    http://us3.php.net/manual/en/features.file-upload.php

    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

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


  7. #7
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  8. #8
    Andy128's Avatar
    Andy128 is offline Major General
    Join Date
    Dec 2005
    Location
    Michigan
    Posts
    2,322

    Default 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!

  9. #9
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default 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!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49